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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:13:44  来源:igfitidea点击:

Conversion from string "" to long is not valid

vb.netconcatenation

提问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