|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
||||
|
||||
|
Hi all,
is there a possibility in VB to determine the size of an array? I have the following piece of code: Code:
stringArray = Split(Trim(str_array(1)), "/", 3) MsgBox (stringArray(2)) The problem occurs when there is a string that doesn't contain "/". Then I get an error message "Subscript out of Range". Any ideas? |
|
#2
|
||||
|
||||
|
Code:
stringArray = Split(Trim(str_array(1)), "/", 3)
If 0 <> LBound(stringArray) Then
MsgBox (stringArray(2))
EndIf
|
|
#3
|
|||
|
|||
|
Will this work for me?
I am working with a vbscript. After a call to a database the results are places into an array. I would like to randomly select a value from the array. However the record set will be very dynamic. Additionally, I would like to test the value returned and select another if it is not suitable. Code:
sql = "Select RNS_P,Count(RNS_P) As Sessions FROM " & glc & " GROUP BY RNS_P ORDER BY Count(RNS_P)" Set rs = db.Execute(sql) IPArray = RS.GetRows() rnsp = IPArray(0, 0) At this point I need to determine how many rows are in the array. Once that is know I can use it to generate a random number and make a selection for new variable and test it. Any help would be appreciated. |
|
#4
|
|||
|
|||
|
I have answered my own question.
Code:
sql = "Select RNS_P,Count(RNS_P) As Sessions FROM " & glc & " GROUP BY RNS_P ORDER BY Count(RNS_P)" Set rs = db.Execute(sql) IPArray = RS.GetRows() rnsp = IPArray(0, 0) upper = ubound(IPArray,2) Randomize selection = Int((upper - 1 + 1) * Rnd + 1) rnss = IPArray(0, selection) While rnsp = rnss selection = Int((upper - 1 + 1) * Rnd + 1) rnss = IPArray(0, selection) Wend |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > determine the size of an array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|