d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Use A Non-constant In An Array..? > Vb5
Add Reply New Topic New Poll
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Feb 13 2013 08:03pm
Wondering if it would be possible to use a non-constant in an array

ie
Dim pokemon = 1 To Selected_.Text

or
Selected = Selected_.Text
Dim pokemon = 1 To Selected


both these return the error that I have to use a constant
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 13 2013 08:08pm
Why are you using visual basic 5?

in vb6, you can declare it without bounds then determine it at runtime

Dim pokemon() As Variant

This post was edited by carteblanche on Feb 13 2013 08:09pm
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Feb 14 2013 03:54pm
Quote (carteblanche @ Feb 13 2013 09:08pm)
Why are you using visual basic 5?

in vb6, you can declare it without bounds then determine it at runtime

Dim pokemon() As Variant


my prof says using the schools money to go beyond vb5 is useless
..
..
lol

anyways I figured that you could do it this way to anyone viewing this topic wondering the same thing
just Dim variable = 1 To 99999

Then when you use it just do
For variable 1 To Non_Constant

Of course you won't be able to go over a certain amount this way, but for my purpose it was fine.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 14 2013 08:25pm
Quote (0n35 @ Feb 14 2013 05:54pm)
my prof says using the schools money to go beyond vb5 is useless
..
..
lol

anyways I figured that you could do it this way to anyone viewing this topic wondering the same thing
just Dim variable = 1 To 99999

Then when you use it just do
For variable 1 To Non_Constant

Of course you won't be able to go over a certain amount this way, but for my purpose it was fine.


there are so many better FREE alternatives to vb5 it's not even funny. python, ruby, perl, pascal and all its variants, c flavours. why is your school teaching vb5 lol?

also just an ify it is impossible to define an array to a non constant in any modern language. if you need run time flexibility you need to allocate the memory yourself. (c, c++, C#). ii dont understand why your university is teaching you bad habits right off the bat...

This post was edited by AbDuCt on Feb 14 2013 08:27pm
Member
Posts: 35,456
Joined: Jan 25 2009
Gold: 1,173.00
Feb 15 2013 02:00am
Quote (AbDuCt @ 14 Feb 2013 21:25)
there are so many better FREE alternatives to vb5 it's not even funny. python, ruby, perl, pascal and all its variants, c flavours. why is your school teaching vb5 lol?

also just an ify it is impossible to define an array to a non constant in any modern language. if you need run time flexibility you need to allocate the memory yourself. (c, c++, C#). ii dont understand why your university is teaching you bad habits right off the bat...


I was not aware AbDuCt knew of such coding and had such skills. Sushi will begin picking your brain now; your fate is sealed. :evil:
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 15 2013 11:05am
Quote (NinjaSushi2 @ Feb 15 2013 04:00am)
I was not aware AbDuCt knew of such coding and had such skills. Sushi will begin picking your brain now; your fate is sealed.  :evil:


i mostly post in the C section, but my languages and general knowledge spreads to other subjects.
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Feb 15 2013 05:01pm
Quote (AbDuCt @ Feb 14 2013 09:25pm)
there are so many better FREE alternatives to vb5 it's not even funny. python, ruby, perl, pascal and all its variants, c flavours. why is your school teaching vb5 lol?

also just an ify it is impossible to define an array to a non constant in any modern language. if you need run time flexibility you need to allocate the memory yourself. (c, c++, C#). ii dont understand why your university is teaching you bad habits right off the bat...


i have to take "basic" programming classes before going on further..

already teaching myself ruby since it's most relevant to what I'll be dealing with
I've tried perl, hated it, python was better, but ruby is damn sexy
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll