我在 VB.Net 中做了一个简单的函数 get 获取您在文本框一中键入的字符串,并通过 webbrower 将其发送到文本框 id“wgo”,然后单击提交。它给了我警告“函数 GetMessage()不在所有代码路径上返回一个值”。如果有人知道如何修复警告,或者如何以不同的格式捕获 textbox1.text 消息;请告诉我。
这是我正在使用的部分代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim elements = WebBrowser1.Document.GetElementsByTagName("input") '' or whatever tag it is
For Each element As HtmlElement In elements
GetMessage() 'Get message from textbox1 and send it
If element.GetAttribute("className") = "submitbut" Then
element.InvokeMember("click")
MsgBox("Your ECHO has been broadcast!")
Exit For
End If
Next
TextBox2.Text = TextBox1.Text 'Displays what the sent message was
TextBox1.Text = "" 'Erases old message from textbox1
TextBox3.Text = getCurrentDateTimeString() 'Displays the time and date it was sent
End Sub
Function GetMessage()
WebBrowser1.Document.GetElementById("wgo").SetAttribute("value", TextBox1.Text)
End Function
任何帮助,将不胜感激!我是 VB.net 的新手,所以放轻松!再次感谢!