.net MsgBox不能处理多个字符串
当我使用此代码时:.net MsgBox不能处理多个字符串,.net,vb.net,.net,Vb.net,当我使用此代码时: Dim sessionid = "sessionid = " + """" + TextBox2.Text + """" Dim steamlogin = "steamLogin = " + """" + TextBox3.Text + """" Dim steamparental = "steamparental = " + """" + """" Dim sortextera = "sort = " + """" + """" MsgBox(SettingsDir, se
Dim sessionid = "sessionid = " + """" + TextBox2.Text + """"
Dim steamlogin = "steamLogin = " + """" + TextBox3.Text + """"
Dim steamparental = "steamparental = " + """" + """"
Dim sortextera = "sort = " + """" + """"
MsgBox(SettingsDir, sessionid + steamlogin + steamparental + sortextera, True)
VisualBasic出现一个错误,表示无法将其转换为字符串。
有什么帮助吗?
MsgBox
要求将a作为第二个参数,而不是字符串。因此,这应该是可行的:
MsgBox(SettingsDir, MsgBoxStyle.Information, sessionid + steamlogin + steamparental + sortextera)
(我也不知道布尔值作为最后一个参数的用途)
我也更喜欢:
- 使用
而不是VB6MessageBox.Show
与.NET兼容MsgBox
- 使用
而不是&
进行字符串连接,因为+
是专门为字符串定义的,而不是&
,并减少生成意外转换的机会+
- 使用
格式化字符串:String.Format
Dim message = String.Format("sessionid = ""{0}"" steamLogin = ""{1}"" steamparental = ""{2}"" sort = ""{3}""", TextBox2.Text, TextBox3.Text, "", "")
MsgBox
要求将a作为第二个参数,而不是字符串。因此,这应该是可行的:
MsgBox(SettingsDir, MsgBoxStyle.Information, sessionid + steamlogin + steamparental + sortextera)
(我也不知道布尔值作为最后一个参数的用途)
我也更喜欢:
- 使用
而不是VB6MessageBox.Show
与.NET兼容MsgBox
- 使用
而不是&
进行字符串连接,因为+
是专门为字符串定义的,而不是&
,并减少生成意外转换的机会+
- 使用
格式化字符串:String.Format
Dim message = String.Format("sessionid = ""{0}"" steamLogin = ""{1}"" steamparental = ""{2}"" sort = ""{3}""", TextBox2.Text, TextBox3.Text, "", "")
选项STRICT
设置为打开
或关闭
?另外,如果您连接字符串,请在VB.NET中使用&
,因为&
是专门为字符串定义的,而不是+
,这样可以减少生成非预期转换的机会。什么是SettingsDir变量?您是否将OPTION STRICT
设置为打开
或关闭
?另外,如果您连接字符串,请在VB.NET中使用&
,因为&
是专门为字符串定义的,而不是+
,这样可以减少生成意外转换的机会。SettingsDir变量是什么?谢谢!你修好了:)谢谢!你修好了:)