Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-21-2003, 07:19 PM   #1
AssFairy
Confirmed User
 
Join Date: Jun 2003
Location: AssTown
Posts: 674
:tongue I need help with VB

I want to fill an array with data but there must be an easier way than this.

Dim MyArray$(7)
MyArray$(1) = "Monday"
MyArray$(2) = "Tuesday"
MyArray$(3) = "Wednesday"

What I really want is something like this.

Dim MyArray$(7)
Data "Monday","Tuesday","Wednesday" .....

then use a loop to add the data to the array.


I could store the data in a text file and read it in like this

Open "data.txt" For Input As #1
Do
x = x + 1
Input #1, a$
MyArray$(x) = a$
Loop Until EOF(1)
Close

but I want my data string to be stored within the program.

__________________
I sale lube
AssFairy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2003, 07:27 PM   #2
cluck
Confirmed User
 
Join Date: Dec 2002
Location: New Jersey
Posts: 5,248
You could store them as comma delimited or whatever then use a function to loop through them and put them in an array I guess.
__________________
icq 279990726
www.mcdonalds.com <- great money making opportunity
cluck is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2003, 07:29 PM   #3
MrSpeed
Confirmed User
 
Join Date: May 2003
Posts: 158
There aren't too many different ways.

<% Dim mArray(11)
mArray=Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
%>
MrSpeed is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2003, 07:33 PM   #4
gornyhuy
Chafed.
 
gornyhuy's Avatar
 
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
2 ways come to mind and there are probably better ones:

1)define a string variable with comma delimeters and then use a string tokenizer

or

2)similar to above but use the SPLIT() function which automatically tokenizes a string and returns an array with all the tokens as the array elements.

have fun!
__________________

icq:159548293
gornyhuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2003, 07:44 PM   #5
AssFairy
Confirmed User
 
Join Date: Jun 2003
Location: AssTown
Posts: 674
Quote:
Originally posted by gornyhuy
2 ways come to mind and there are probably better ones:

1)define a string variable with comma delimeters and then use a string tokenizer

or

2)similar to above but use the SPLIT() function which automatically tokenizes a string and returns an array with all the tokens as the array elements.

have fun!
??? there is no "Split()" command in VB!

In old basics you could just use the "Data" and "Read" but VB don't appear to have such a function.

If you gad a string like .... MyData$="Monday,Tuesday,Wednesday,Thursday"
how would you put them into an array?
__________________
I sale lube
AssFairy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2003, 09:35 PM   #6
gornyhuy
Chafed.
 
gornyhuy's Avatar
 
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
RTFM.

http://msdn.microsoft.com/library/de...vafctsplit.asp

I'm done helping you.
__________________

icq:159548293
gornyhuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-22-2003, 09:21 AM   #7
evilregis
Confirmed User
 
Join Date: Oct 2003
Location: Canada
Posts: 163
Dim Days() as String = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }

remember VB starts its arrays at 0... so sunday is day(0) not day(1).
__________________
eR
:: beauty is in the eye of the beer-holder ::
evilregis is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-22-2003, 10:09 AM   #8
init
Confirmed User
 
Join Date: Oct 2002
Location: Sarasota, FL
Posts: 973
here is a little code i threw up, shows you start with a string then add's data to it. hope this is what you were looking for



Function Dates()
Dim strDay As String, iCount As Integer

strDay = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday ,Sunday"

strDates = Split(strDay, ",")

For iCount = LBound(strDates) To UBound(strDates)


strDates(iCount) = strDates(iCount) & " Index (" & iCount & ")" & vbNewLine

MsgBox strDates(iCount)

Next iCount

End Function
__________________
icq: 2721653
init is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-22-2003, 10:26 AM   #9
gornyhuy
Chafed.
 
gornyhuy's Avatar
 
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
Quote:
Originally posted by init
here is a little code i threw up, shows you start with a string then add's data to it. hope this is what you were looking for



Function Dates()
Dim strDay As String, iCount As Integer

strDay = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday ,Sunday"

strDates = Split(strDay, ",")

For iCount = LBound(strDates) To UBound(strDates)


strDates(iCount) = strDates(iCount) & " Index (" & iCount & ")" & vbNewLine

MsgBox strDates(iCount)

Next iCount

End Function
Nice use of SPLIT...
__________________

icq:159548293
gornyhuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-22-2003, 10:31 AM   #10
init
Confirmed User
 
Join Date: Oct 2002
Location: Sarasota, FL
Posts: 973
Quote:
Originally posted by gornyhuy


Nice use of SPLIT...
thanks you :p , easiest peice of code i ever wrote i think
__________________
icq: 2721653
init is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-22-2003, 11:39 AM   #11
AssFairy
Confirmed User
 
Join Date: Jun 2003
Location: AssTown
Posts: 674
Quote:
Originally posted by gornyhuy
RTFM.

http://msdn.microsoft.com/library/de...vafctsplit.asp

I'm done helping you.
Thanks for the link and taking your time out to help
Unfortunately its not supported in my old version of VB, I guess its time to upgrade.
__________________
I sale lube
AssFairy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-22-2003, 11:47 AM   #12
AssFairy
Confirmed User
 
Join Date: Jun 2003
Location: AssTown
Posts: 674
Quote:
Originally posted by evilregis
Dim Days() as String = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }

remember VB starts its arrays at 0... so sunday is day(0) not day(1).
Dam.... even this function is not supported in VB5
I feel so old and out of date
__________________
I sale lube
AssFairy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.