loops

vks.gautam1

Well-known member
Joined
Oct 10, 2008
Messages
78
Location
Chandigarh, India
Programming Experience
Beginner
It is about using loop in VB.NET?
im using For loop. I type a text in first text box & on command button click this is my code.

str=textbox1.text
dim i as integer
for i=0 to str.length-1
textbox2.text=str(i)+textbox2.text
next

TB1=VIVEK
RESULT
TB2=KEVIV

HOW THIS IS HAPPENING. Pls tell me in Simple manner.
 
What is it exactly that you are questioning? The code above seems to be valid for the results you give...

Are you trying to NOT reverse the string perhaps?
 
It is about using loop in VB.NET?
im using For loop. I type a text in first text box & on command button click this is my code.

str=textbox1.text
dim i as integer
for i=0 to str.length-1
textbox2.text=str(i)+textbox2.text
next

TB1=VIVEK
RESULT
TB2=KEVIV

HOW THIS IS HAPPENING. Pls tell me in Simple manner.
This is happening because you're looping through the string and putting each character from the beginning to end from the first string and placing it at the beginning of the second string, which the result is a reversed string which (surprisingly) is the result you're getting
 
VB.NET:
For each c as char in str.ToCharArray

'this is how i look through each character in a string in VB.NET
'For eaches rule!!!!

Next


:cool::cool:
In .Net that's how I would do this too, but given the code vks.gautam1 posted, I think it originally came from an older language like vb6.
 
It is about using loop in VB.NET?
im using For loop. I type a text in first text box & on command button click this is my code.

str=textbox1.text
dim i as integer
for i=0 to str.length-1
textbox2.text=str(i)+textbox2.text
next

TB1=VIVEK
RESULT
TB2=KEVIV

HOW THIS IS HAPPENING. Pls tell me in Simple manner.


Thanks to all & specaily to JuggaloBrotha.
as i already know about loops but i was confused .
JuggaloBrotha clears that the inverse result trick is in this textbox2.text=str(i)+textbox2.text. so thanks.
 
Back
Top