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
Printable View
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
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
UBound() returns the last index in the folding() array. You can alsow use LBound(), which returns the first index of array.
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?
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:
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 :)VB Code:
result = result + CLng(Val(Right(txtInput(i).Text, Len(folding(UBound(folding))))))
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.Quote:
Originally Posted by belvita
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?
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:
Now you have:VB Code:
folding() = Split(txtFolding.Text, "+")
folding(0)=1
folding(1)=234
folding(2)=5
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:
result = result + 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? :ehh:VB Code:
Val(Mid(txtNumber(i).Text, Left(folding(j), 1), Len(folding(j))))
yes...thanks gavio