RichTextBox: How to get the count of tabs in a TextLine
-
I wrote a simple dBase Program Editor for Program Files. Now I wanted to add the following functionnality: IF X=0 DO XPRG ENDI ---> IF X=0 DO XPRG ENDI For this method I need the count of tabs in a line (because of reloading, when tabs already are set). The Problem is that Line.IndexOf("\t") does not return the right value (RichTextBox always find this value and never returns -1). So how is it possible to determine how much tabs are in a StringLine? Or is there another way to solve this problem? Thanks. Stefan
-
I wrote a simple dBase Program Editor for Program Files. Now I wanted to add the following functionnality: IF X=0 DO XPRG ENDI ---> IF X=0 DO XPRG ENDI For this method I need the count of tabs in a line (because of reloading, when tabs already are set). The Problem is that Line.IndexOf("\t") does not return the right value (RichTextBox always find this value and never returns -1). So how is it possible to determine how much tabs are in a StringLine? Or is there another way to solve this problem? Thanks. Stefan
C#:
private void Form1_Load(object sender, System.EventArgs e)
{
richTextBox1.AppendText("some\ttext\twith\ttabs\tin\tthere"); /// 5 tabs in a line.
}private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(richTextBox1.Lines[0].Split('\t').GetUpperBound(0).ToString()); // 0 is the first line in the richtextbox, upperbound is the count of tabs.
}
hope that helps :) Vb:
Public Function TwinsOnWay(ByVal twins As String) As String
Select Case twins
Case "Gender"
Return "Two Girls"
End Select
End Function
-
C#:
private void Form1_Load(object sender, System.EventArgs e)
{
richTextBox1.AppendText("some\ttext\twith\ttabs\tin\tthere"); /// 5 tabs in a line.
}private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(richTextBox1.Lines[0].Split('\t').GetUpperBound(0).ToString()); // 0 is the first line in the richtextbox, upperbound is the count of tabs.
}
hope that helps :) Vb:
Public Function TwinsOnWay(ByVal twins As String) As String
Select Case twins
Case "Gender"
Return "Two Girls"
End Select
End Function