0

I'm new to vb.net and English is not my first language, Please note this :)

I know Value of type string cannot be converted to String() but how to fix it.... help me!
This is my code below here, I don't know how to add each line of richtextbox into array

I want 'itvalue' to array :(

For v = 8 To 18
  Dim myArr As String() = richtextbox.Lines(v)
Next

' i want ↓  to  ↑ 

For linerepeat As Integer = 1 To 3 '
   If linerepeat = 3 Then 
       i -= 3
   Else 
      i = 5 
   End If

    Dim itvalue As String
    itvalue = Mid(ReceiveBox.Lines(8), h, i)
    itvalue = Mid(ReceiveBox.Lines(9), h, i)
                  ·
                  ·
                  ·
    itvalue = Mid(ReceiveBox.Lines(18), h, i)
    h += 7
    If h = 29 Then Exit For
Next
2
  • 1
    Mid() exists for backwards compatibility with old pre-.Net VB and should not be used in new code. You should use string.SubString() instead. Commented Apr 6, 2022 at 2:25
  • 1
    That's some crazy looking code; hard to decipher what is happening (or what is SUPPOSED to happen). Can you show the contents of the RTB along with your expected output of what you want to extract? Commented Apr 6, 2022 at 2:50

1 Answer 1

1
Dim itvalue() As String =
    ReceiveBox.Lines.Skip(8).
                     Take(11).
                     Select(Function(line) line.SubString(h, i)).
                     ToArray()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.