简体   繁体   English

使用VB.net发送收到的SMS

[英]Sending Received SMS using VB.net

Hi there i have a fully running SMS application which performs 2 way process of sending and receiving. 嗨,我有一个完全运行的SMS应用程序,它执行2种发送和接收过程。 I am now on the part of Sending the Received SMS. 我现在正在发送接收的SMS。 I will just assure that I am receiving SMS so ill just show the codes of the splitting part. 我会向您保证我会收到短信,所以请只显示拆分部分的代码。

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

There i used the split function to cut the message into 3 parts. 在那里,我使用了split功能将消息分为3部分。 If the message says "abc_123_432" then the pass,txt,recipients would have abc,123,432 respectively but separated. 如果消息中显示“ abc_123_432”,则pass,txt,收件人将分别具有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()

I would just want to specify that when i sent SMS to my application, it surpasses this part because when i checked my inbox table, it shows the right message which I've sent. 我只想指定当我向应用程序发送SMS时,它已经超过了此部分,因为当我检查收件箱表时,它显示了我已发送的正确消息。 On the following codes I didnt know where it went wrong there. 在以下代码上,我不知道哪里出错了。

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

I also tried to make the pass1 and pass2 appear in a messagebox before comparing, but still it wont pass through even though they are exactly thesame. 在比较之前,我还尝试使pass1和pass2出现在消息框中,但是即使它们完全相同,也不会通过。 Please help me guys, i just need the needed code As Soon As Possible, thanks 请帮助我,我只需要所需的代码,谢谢

Change 更改

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

to

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

also why are you using = when comparing STRINGS??? 还有为什么在比较STRINGS时使用=? Try this: 尝试这个:

If pass2.equals(pass1) Then

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM