1,105,352 Community Members

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

Member Avatar
RaoxFaello
Newbie Poster
9 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
Ancient Dragon
Achieved Level 70
27,591 posts since Aug 2005
Reputation Points: 5,232 [?]
Q&As Helped to Solve: 3,032 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

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

Member Avatar
RaoxFaello
Newbie Poster
9 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
tinstaafl
Postaholic
2,012 posts since Jun 2010
Reputation Points: 559 [?]
Q&As Helped to Solve: 402 [?]
Skill Endorsements: 35 [?]
 
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.

Member Avatar
RaoxFaello
Newbie Poster
9 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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