0

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 :)

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by TnTinMN
1
     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
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.