hello bros

i need help in dis

i have textbox with text

blahbla@lablablab
blahblabla@alalalala
blahbla@lablablab
blahblabla@alalalala

multi line and so on

i would trim all text after the "@"

to be

blahbla
blahblabla
blahbla
blahblabla

thx in advance my bros :)

     Dim lines() As String
        lines = TextBox1.Lines
        Dim amper As Integer = 0
        For Each l In lines
          amper = l.IndexOf("@")
          MsgBox(l.Remove(amper, l.Length - amper))
        Next

Assuming that you intended to replace the text in the textbox with the trimmed text,

   Dim index As Int32
   Dim trimmedtext As New System.Text.StringBuilder(TextBox1.Text.Length)
   For i As Int32 = 0 To TextBox1.Lines.Length - 1
      index = TextBox1.Lines(i).IndexOf("@")
      If index <> -1 Then
         'add trimmed line characters
         trimmedtext.Append(TextBox1.Lines(i), 0, index)
      Else
         trimmedtext.Append(TextBox1.Lines(i))
      End If
      trimmedtext.Append(vbCrLf)
   Next
   TextBox1.Text = trimmedtext.ToString
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.