1.11M Members

How to determine the Index of what i type in a Textbox

 
0
 

I'm trying to create a program that determines if what i inputted is a Literal (String or a Char)
My idea on how to create one is if i inputted a string (Starts with the usual ") so the first Index in my Array should be " or else it will show invalid same with the last index it should be ".

So my problem is i don't know how. If i input something in a Textbox (Example: Daniweb) my program should automatical determine that an Array has 6 indexes, Can someone help me.

 
0
 

Use substr() method e.g. if textBox1.Text.Substring(0,1) = '"' then

 
0
 

Thanks for replying but i have one problem, It's not dynamic.
What if i type something that has larger numbers and letters and the one in the code is fixed it will give me Invalid.

 
0
 

Use the Textbox1.Text.Length property.

Any string is basically a character array. You can read the individual characters with an index, Textbox1.Text(0). The last character, without using LINQ, like this, Textbox1.Text(TextBox1.Text.Length-1). With LINQ, TextBox1.Text.Last().

A simple conditional statement to test, If Not(TextBox1.Text(0) = """"c) Or Not(TextBox1.Text(TextBox1.Text.Length-1) = """"c) Then.

 
0
 

Thank you every much.
I was so fixed on using something more complicated like what i've suggested with the indexes and arrays
whereas i didn't even know there's a Property like that, I really need to read more.

Question Answered as of 1 Year Ago by Ancient Dragon and tinstaafl
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article