GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   I need help with VB (https://gfy.com/showthread.php?t=188558)

AssFairy 10-21-2003 07:19 PM

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.

:helpme

cluck 10-21-2003 07:27 PM

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.

MrSpeed 10-21-2003 07:29 PM

There aren't too many different ways.

<% Dim mArray(11)
mArray=Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
%>

gornyhuy 10-21-2003 07:33 PM

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!

AssFairy 10-21-2003 07:44 PM

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?
:helpme

gornyhuy 10-21-2003 09:35 PM

RTFM.

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

I'm done helping you.

evilregis 10-22-2003 09:21 AM

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).

init 10-22-2003 10:09 AM

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 :thumbsup



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

gornyhuy 10-22-2003 10:26 AM

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 :thumbsup



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... :winkwink:

init 10-22-2003 10:31 AM

Quote:

Originally posted by gornyhuy


Nice use of SPLIT... :winkwink:

thanks you :p , easiest peice of code i ever wrote i think :thumbsup

AssFairy 10-22-2003 11:39 AM

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 :thumbsup
Unfortunately its not supported in my old version of VB, I guess its time to upgrade.

AssFairy 10-22-2003 11:47 AM

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 :1orglaugh


All times are GMT -7. The time now is 08:28 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123