IBM developerWorks
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 23rd, 2003, 06:33 AM
Wizard2003's Avatar
Wizard2003 Wizard2003 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 206 Wizard2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 29 m 24 sec
Reputation Power: 6
Question determine the size of an array

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?

Reply With Quote
  #2  
Old July 23rd, 2003, 08:01 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Code:
stringArray = Split(Trim(str_array(1)), "/", 3)
If 0 <> LBound(stringArray) Then
    MsgBox (stringArray(2))
EndIf

Reply With Quote
  #3  
Old August 25th, 2003, 10:52 AM
Pullox Pullox is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: TN
Posts: 2 Pullox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old August 25th, 2003, 01:04 PM
Pullox Pullox is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: TN
Posts: 2 Pullox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > determine the size of an array


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway