【问题标题】:Sending Received SMS using VB.net使用 VB.net 发送收到的短信
【发布时间】:2015-03-28 09:51:50
【问题描述】:

您好,我有一个完全运行的 SMS 应用程序,它执行 2 路发送和接收过程。我现在参与发送收到的短信。 我只是保证我正在接收短信,所以我只显示拆分部分的代码。

        '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)

我使用 split 功能将消息分成 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 时,它超过了这部分,因为当我检查我的收件箱表时,它显示了我发送的正确消息。在下面的代码中,我不知道哪里出错了。

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 出现在消息框中,但即使它们完全相同,它仍然不会通过。请帮助我,我只需要尽快所需的代码,谢谢

【问题讨论】:

    标签: vb.net sms


    【解决方案1】:

    改变

    Dim textmess As String() = Message.Split("_")
    

     Dim textmess As String() = Split(Message,"_")
    

    还有你为什么在比较字符串时使用 = ??? 试试这个:

    If pass2.equals(pass1) Then
    

    【讨论】:

      猜你喜欢
      • 2012-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多