问题
I'm getting an error which i can't solve, even after about an hour of research.
Conversion from String "Waseem-PC\Waseem" to long is not valid
This error really gets annoying, I tried everything!
I would really appreciate help from you. I would love to give your answers a thumbs up but i have to have a bigger rep.
Here is my code
Private Sub RichTextBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RichTextBox2.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then
RichTextBox1.Text = RichTextBox1.Text And vbNewLine And RichTextBox2.Text
End If
End Sub
回答1:
You're incorrectly using the And keyword which is used for (from MSDN):
Perform a logical conjunction on two Boolean expressions, or bitwise conjunction on two numeric expressions.
Instead you want to use &
to concatenate the strings...
This will work:
Private Sub RichTextBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RichTextBox2.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then
RichTextBox1.Text = RichTextBox1.Text & vbNewLine & RichTextBox2.Text
End If
End Sub
来源:https://stackoverflow.com/questions/14726120/conversion-from-string-to-long-is-not-valid