|
-
Sep 20th, 2006, 05:53 AM
#1
Thread Starter
Just Married
Upper Bound Of Array
Hi all
How to found the upper bound of the array without using the redim value
Check the code error in the command 2 click then how to solve this error without using the value of the text1.text
VB Code:
Dim A() As Integer
Private Sub Command1_Click()
Dim I As Integer
ReDim A(Val(Text1.Text))
For I = 0 To Text1.Text
A(I) = I * 1
Next
End Sub
Private Sub Command2_Click()
'Without Using the value of Text1.Text How we founnd the UpperBound Of Array A
'I Want
For I = 0 To [B]A.ubound 'Error Here[/B] :confused:
MsgBox A(I)
Next
End Sub
Hope you all understand the problem I have a lot of array and I want to know the ubound value at run time without saving the other value
Thanks
-
Sep 20th, 2006, 05:58 AM
#2
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Sep 20th, 2006, 06:01 AM
#3
Re: Upper Bound Of Array
Shouldnt that be ubound(a) ?? and btw fir command1_click the line
for i=0 to text1.text is wrong it should be val(text1.text)
__________________
________________0îîî___
___îîî0________(___)____
__(___)_________) _/_____
___\_ (_________(_/______
____\_)_________________
-
Sep 20th, 2006, 06:07 AM
#4
Thread Starter
Just Married
Re: Upper Bound Of Array
 Originally Posted by Shuja Ali
Thanks but I want random value from the saved array, so what to do?
-
Sep 20th, 2006, 06:09 AM
#5
Re: Upper Bound Of Array
 Originally Posted by shakti5385
Thanks but I want random value from the saved array, so what to do? 
I don't understand what bearing this has on the orginal question.
A random value may not always be, in fact, may never be, it upper boundary.
-
Sep 20th, 2006, 06:23 AM
#6
Re: Upper Bound Of Array
your code in the first post doesn't make any sense at all.
you're creating an array of integers where A(1) = 1, A(2) = 2 etc., so in order to get the member which has the value 2 you have to access the member with index 2 and hence you already know the number - why bother with the array?????
-
Sep 20th, 2006, 06:40 AM
#7
Lively Member
Re: Upper Bound Of Array
try this one
VB Code:
Dim A(5) As String
Private Sub Command1_Click()
Dim index As Integer
Math.Randomize
index = Math.Rnd * UBound(A)
MsgBox A(index)
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To UBound(A)
A(i) = "Item " & i
Next i
End Sub
-
Sep 20th, 2006, 06:52 AM
#8
Thread Starter
Just Married
Re: Upper Bound Of Array
 Originally Posted by bushmobile
your code in the first post doesn't make any sense at all.
you're creating an array of integers where A(1) = 1, A(2) = 2 etc., so in order to get the member which has the value 2 you have to access the member with index 2 and hence you already know the number - why bother with the array????? 
I AM MAKING THE ARRAY BECAUSE I AM USING MORE THEN 2 array in my project, what’s happening that I am finding the teacher code related to the class code, and next I am finding the value of subject code related to the teacher code so I need the upper bound of the array.
But now I want random subject code related to the teacher’s code so I want to get the random value from the saved array.
Thanks
-
Sep 20th, 2006, 07:01 AM
#9
Lively Member
Re: Upper Bound Of Array
Did my answer solve ur problems?
-
Sep 20th, 2006, 07:45 AM
#10
Thread Starter
Just Married
Re: Upper Bound Of Array
 Originally Posted by balajikandaswamy
Did my answer solve ur problems?
Your effort is good but i am thinking that how to apply
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|