What is syntax for reading a specific line from a multiline textbox?

Hello & Thanks ;

I have spent hours searching the internet ,

to find out what is the syntax for reading a specific line from a multiline textbox .

Why aren’t there good docs for vb.net windows forms for .vb

like there are for C# ?

Anyone know of such a site ?

Do you mean you are trying to split the multiple lines into a string array so you can iterate over them or are you looking for a specific string in the text?

You can use use Regex.Split on Environment.NewLine to split the text into an array. Or you can use .IndexOf to find where the text you are seeking is positioned.

Thanks ;
The most important part of my question is this ::
[ I have spent hours searching the internet ,
to find out what is the syntax for reading a specific line from a multiline textbox .
Why aren’t there good docs for vb.net windows forms for .vb
like there are for C# ?
Anyone know of such a site ? ]

I am looking for the syntax of this statement ::
If txbAddress.Text = TextBox2.Lines[i]
Here is the code =

    Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        HitYes = "no"
        txbAddress.Text = WebBrowser1.Url.ToString
        Textboxt2LinesCount = TextBox2.Lines.Length()
        For i = 0 To Textboxt2LinesCount - 1
            '            MsgBox("Textboxt2LinesCount =  " & i)
            If txbAddress.Text = TextBox2.Lines[i] Then
                MsgBox("We have a hit people = " & TextBox2.Lines[i])
                CheckingLine = TextBox2.Lines[i]
                HitYes = "yes"
                Exit For
            End If
        Next
        If HitYes = "no" Then
            MsgBox("We have a NO HITs people = " & CheckingLine)
        End If
    End Sub

Thanks

Just about every C# doc you find can be adapted for VB.NET, the syntax when it comes to LINQ to Object changes, but everything else is near identical.

I’m confused, what you posted is near syntax that vb.net honors, so there is nothing to alter, it is simply doing an equality check. Does txbAddress.Text equal the the line we’re iterating on from the multiline textbox.

By the way, you can develop windows forms in C# if you want to, then you don’t have to interpret the syntax.

Thanks ;

Blockquote Just about every C# doc you find can be adapted for VB.NET, the syntax when it comes to LINQ to Object changes, but everything else is near identical.

If that’s true , please show me the C# version of this .vb code =
MsgBox("We have a hit people = " & TextBox2.Lines[i])
(btw: the above .vb code causes an error , program won’t compile) . That’s why I am here seeking .vb syntax .
Better yet aim me at a site where I can see for myself .

BTW: What is LINQ ?

Thanks

MessageBox.Show("We have a hit people = " + TextBox2.Lines[i]);

LINQ is Language Integrated Query, it is a way to query object structures.

What error is it giving? As like I said, it is close to VB.NET syntax, but likely is erroring due to syntax/framework changes.

For example, try changing it to:

MessageBox.Show("We have a hit people = " & TextBox2.Lines[i])

You can view the MessageBox syntax at

You can also toggle it between C# and VB by clicking the C# in the top right and changing it to VB.

Thanks ;
It is not the MsgBox that I am interested ,
it is this statement TextBox2.Lines[i]) within MsgBox that is failing .
Also

You can also toggle it between C# and VB by clicking the C# in the top right and changing it to VB.
?? I can see no C# toggle option , only Copy option??

Thanks for your help…

but everything else is near identical

near doesn’t count
Thanks

THanks ;
for your help .
I found what I am looking for here :slight_smile:
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/

And yet you haven’t told me the error you are receiving. If you are truly using VB.NET then that MsgBox command is indeed failing, as that does not exist in VB.NET.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.