使用 VB.net 发送收到的短信
Sending Received SMS using VB.net
您好,我有一个完整的 运行 SMS 应用程序,它执行发送和接收的两种方式。我现在正在发送收到的短信。
我会确保我收到的短信很糟糕,只是显示拆分部分的代码。
'Split parts of the Message Received by "_"
Dim textmess As String() = Message.Split("_")
Dim pass As String = textmess(0)
Dim txt As String = textmess(1)
Dim recipients As String = textmess(2)
我使用拆分功能将消息分成 3 部分。如果消息显示 "abc_123_432" 那么 pass,txt,recipients 将分别有 abc,123,432 但分开。
'Verify Number for Authorization
myr.Close()
mycom.Connection = cn
mycom.CommandText = "Select MobileNum,Name,UserName,Password,Position from tbl_user where MobileNum='" & Number1 & "'"
myr = mycom.ExecuteReader()
If myr.Read Then
Dim num As String = myr(0).ToString
Dim name As String = myr(1).ToString
Dim user As String = myr(2).ToString
Dim pass2 As String = myr(3).ToString
Dim post As String = myr(4).ToString
If num = Number1 Then
myr.Close()
mycom.CommandText = "Insert into tbl_inbox(message,received_date,sender) values ('" & Message & "','" & DateAndTime.Now.ToString & "','" & name & "');"
myr = mycom.ExecuteReader
myr.Close()
我只想说明,当我向我的应用程序发送 SMS 时,它超过了这部分,因为当我检查我的收件箱 table 时,它显示了我发送的正确消息。下面的代码我也不知道哪里错了
If pass2 = pass1 Then
mycom.CommandText = "Insert into tbl_activity(UserName,Activity,CDate) values ('" & user & "','Send SMS to System','" & DateAndTime.Now.ToString & "');"
myr = mycom.ExecuteReader
Form1.txtnumber.Text = recipients
Form1.txtmessage.Text = txt
Form1.btnSend.PerformClick()
Else
MessageBox.Show(pass1)
MessageBox.Show(txt)
MessageBox.Show(recipients)
End If
End If
End If
myr.Close()
End If
我也试过让pass1和pass2出现在一个messagebox中再比较,但是即使完全一样还是传不过去。请帮助我,我只需要尽快获得所需的代码,谢谢
改变
Dim textmess As String() = Message.Split("_")
至
Dim textmess As String() = Split(Message,"_")
另外,为什么在比较 STRINGS 时使用 =???
试试这个:
If pass2.equals(pass1) Then
您好,我有一个完整的 运行 SMS 应用程序,它执行发送和接收的两种方式。我现在正在发送收到的短信。 我会确保我收到的短信很糟糕,只是显示拆分部分的代码。
'Split parts of the Message Received by "_"
Dim textmess As String() = Message.Split("_")
Dim pass As String = textmess(0)
Dim txt As String = textmess(1)
Dim recipients As String = textmess(2)
我使用拆分功能将消息分成 3 部分。如果消息显示 "abc_123_432" 那么 pass,txt,recipients 将分别有 abc,123,432 但分开。
'Verify Number for Authorization
myr.Close()
mycom.Connection = cn
mycom.CommandText = "Select MobileNum,Name,UserName,Password,Position from tbl_user where MobileNum='" & Number1 & "'"
myr = mycom.ExecuteReader()
If myr.Read Then
Dim num As String = myr(0).ToString
Dim name As String = myr(1).ToString
Dim user As String = myr(2).ToString
Dim pass2 As String = myr(3).ToString
Dim post As String = myr(4).ToString
If num = Number1 Then
myr.Close()
mycom.CommandText = "Insert into tbl_inbox(message,received_date,sender) values ('" & Message & "','" & DateAndTime.Now.ToString & "','" & name & "');"
myr = mycom.ExecuteReader
myr.Close()
我只想说明,当我向我的应用程序发送 SMS 时,它超过了这部分,因为当我检查我的收件箱 table 时,它显示了我发送的正确消息。下面的代码我也不知道哪里错了
If pass2 = pass1 Then
mycom.CommandText = "Insert into tbl_activity(UserName,Activity,CDate) values ('" & user & "','Send SMS to System','" & DateAndTime.Now.ToString & "');"
myr = mycom.ExecuteReader
Form1.txtnumber.Text = recipients
Form1.txtmessage.Text = txt
Form1.btnSend.PerformClick()
Else
MessageBox.Show(pass1)
MessageBox.Show(txt)
MessageBox.Show(recipients)
End If
End If
End If
myr.Close()
End If
我也试过让pass1和pass2出现在一个messagebox中再比较,但是即使完全一样还是传不过去。请帮助我,我只需要尽快获得所需的代码,谢谢
改变
Dim textmess As String() = Message.Split("_")
至
Dim textmess As String() = Split(Message,"_")
另外,为什么在比较 STRINGS 时使用 =??? 试试这个:
If pass2.equals(pass1) Then