|
-
Sep 2nd, 2006, 04:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] ubound
a simple question, what does ubound in this code means?
VB Code:
Dim folding() As String
folding() = Split(txtFolding.Text, "+")
If UBound(folding) = 1 Then
result = result + Val(Mid(txtNumber(i).Text, Left(folding(1), 1), Len(folding(1))))
thanks
-
Sep 2nd, 2006, 04:05 AM
#2
Hyperactive Member
Re: ubound
Ubound() returns the upper limit of an array.
Split(txtFolding.text,"+") feeds into an array, seperating a block of text into each array index.
If UBound(folding) = 1 then
Means that there is a + present inside the txtFolding.text
-
Sep 2nd, 2006, 04:06 AM
#3
Re: ubound
UBound() returns the last index in the folding() array. You can alsow use LBound(), which returns the first index of array.
-
Sep 2nd, 2006, 04:12 AM
#4
Thread Starter
Addicted Member
Re: ubound
thanks...
hey gavio,
can I have a favor?
can you explain to me the flow of the program about folding
especially about the left,mid and right function?
-
Sep 2nd, 2006, 04:21 AM
#5
Re: ubound
I have used the Left(), Right() and the Mid() functions because i needed to get values from the suitable txtInput TextBox. I could not always use Mid(), since it doesn't work right, if you're on the left/right side of a string. So i've used Left() and Right(). Maybe that seems complicated, but for example:
VB Code:
result = result + CLng(Val(Right(txtInput(i).Text, Len(folding(UBound(folding))))))
That's just add the length of the last folding process (for example 2 digits) from the txtInput(i) TextBox to the result (btw... Val() returns a number (if somebody would have make a mistake and inputed a non-numeric value) and CLng() converts it to Long, since the result is Long
-
Sep 2nd, 2006, 04:27 AM
#6
Thread Starter
Addicted Member
Re: ubound
wooahh...it's true! that it is so complicated
-
Sep 2nd, 2006, 04:30 AM
#7
Re: ubound
 Originally Posted by belvita
wooahh...it's true! that it is so complicated
Always look at the most middle functions, like in mathematics. You always check the most middle brackets (), what are they doing. What this functions returns, the next left/rigth function gets... and so on, until the first/last one.
-
Sep 2nd, 2006, 04:34 AM
#8
Thread Starter
Addicted Member
Re: ubound
in this part:
VB Code:
result = result + Val(Mid(txtNumber(i).Text, Left(folding(j), 1), Len(folding(j))))
you use the mid function, using the len of the folding?
-
Sep 2nd, 2006, 04:47 AM
#9
Re: ubound
I'll try to explain how have i splited the folding process. For example, if user enters "1+234+5", that means 3 folding processes:
VB Code:
folding() = Split(txtFolding.Text, "+")
Now you have:
folding(0)=1
folding(1)=234
folding(2)=5
VB Code:
result = result + Val(Mid(txtNumber(i).Text, Left(folding(j), 1), Len(folding(j))))
I think that that Mid() was used in a For loop... so... previously, i've looped with i through all txtInput() TextBoxes. Now i've created another loop... i'm using j to loop through all the middle folding processes... folding(0) is calculated with the Left() function and folding(2) is calculated with the Right() function. All the middle folding proccesses are calculated with the Mid() function - in this case only 1, but there can be thousands of theme.
VB Code:
Val(Mid(txtNumber(i).Text, Left(folding(j), 1), Len(folding(j))))
That just means: take number/s from txtNumber(i) - in my case that was txtInput(i), in the length of folding(j) - in this case folding(1) and add theme to result. Is this any clearer?
-
Sep 2nd, 2006, 04:52 AM
#10
Thread Starter
Addicted Member
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
|