如何将文本框中的文本转换为字符串?
How to get the text from a textbox into a string?
我正在使用 Visual Basic 2013 并尝试使用 VB 创建热点。
我在 textbox3.text
中有 WLAN SSID,在 textbox2.text
中有密钥;我怎样才能让它们进入 X 和 Y 位置的 myprocess.StartInfo.Arguments
?
这是我用于按钮的代码 "set hotspot"。
Dim myprocess As New Process()
myprocess.StartInfo.FileName = "netsh"
myprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=*X* key=*Y*"
为了更好地阅读代码,我建议使用其他文本框名称。当然,您必须检查用户输入。
以下代码应该可以满足您的需要,但未经测试:
Dim myprocess As New Process()
Dim strSsId as string = txtSsId.Text
Dim strKey as string = txtKey.Text
myprocess.StartInfo.FileName = "netsh"
myprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow " & _
"ssid=" & strSsID & " key=" & strKey
我找到了 answer.Try 这个。
Dim myprocess As New Process()
Dim label1 As String
Dim label2 As String
label1 = TextBox3.Text
label2 = TextBox2.Text
myprocess.StartInfo.FileName = "netsh"
myprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=*x* key=*y*".Replace("*x*", TextBox3.Text).Replace("*y*", TextBox2.Text)
我正在使用 Visual Basic 2013 并尝试使用 VB 创建热点。
我在 textbox3.text
中有 WLAN SSID,在 textbox2.text
中有密钥;我怎样才能让它们进入 X 和 Y 位置的 myprocess.StartInfo.Arguments
?
这是我用于按钮的代码 "set hotspot"。
Dim myprocess As New Process()
myprocess.StartInfo.FileName = "netsh"
myprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=*X* key=*Y*"
为了更好地阅读代码,我建议使用其他文本框名称。当然,您必须检查用户输入。
以下代码应该可以满足您的需要,但未经测试:
Dim myprocess As New Process()
Dim strSsId as string = txtSsId.Text
Dim strKey as string = txtKey.Text
myprocess.StartInfo.FileName = "netsh"
myprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow " & _
"ssid=" & strSsID & " key=" & strKey
我找到了 answer.Try 这个。
Dim myprocess As New Process()
Dim label1 As String
Dim label2 As String
label1 = TextBox3.Text
label2 = TextBox2.Text
myprocess.StartInfo.FileName = "netsh"
myprocess.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=*x* key=*y*".Replace("*x*", TextBox3.Text).Replace("*y*", TextBox2.Text)