vb.net 从字符串 "" 到 long 的转换无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14726120/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Conversion from string "" to long is not valid
提问by Waseem Shahwan
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
从字符串 "Waseem-PC\Waseem" 到 long 的转换无效
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
采纳答案by Blachshma
You're incorrectly using the Andkeyword which is used for (from MSDN):
您错误地使用了用于(来自 MSDN)的And关键字:
Perform a logical conjunction on two Boolean expressions, or bitwise conjunction on two numeric expressions.
对两个布尔表达式执行逻辑合取,或对两个数值表达式执行按位合取。
Instead you want to use &to concatenatethe 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

