substring

danyeungw

Well-known member
Joined
Aug 30, 2005
Messages
73
Programming Experience
10+
When I used "me.Textbox1.Text.Subtring" I got an error "Overload resolution failed because no accessible 'Substring' accepts this member of arguments." What did I miss?

Thanks.
DanYeung
 
Well, you have to tell the substring method what part of the string you want. You do thins like so:


VB.NET:
me.txtbox1.text = "abcdefgh"
dim StartPosition as int32 = 1
dim StringLength as int32 = 3
dim mySubString as string
mySubString = me.txtbox1.text.substring(StartPosition, StringLength)
 
'now you shoud have "bcd" in the mySubString variable.
I hope this answers your question.

Have fun
G.
If you are happy with my answer, please add a few point to my reputation.
 
Last edited by a moderator:
Here is my code. What was wrong? I got error on Me.TextBoxIn.Text.Substring.

VB.NET:
Dim idx AsInteger
Dim textOut As stringbuilder = New Stringbuilder
For idx = 0 To Len(Me.TextBoxIn.Text) - 1
SelectCase idx
Case 1, 3, 4, 5, 7, 9, 11
textOut.Append(Me.TextBoxIn.Text.Substring, idx, 1)
CaseElse
...
EndSelect
Next
Thanks.
DanYeung
 
Last edited by a moderator:
Back
Top