1

这是我的代码

'用于在 COMBOBOX 中显示所有联系人号码 Private Sub BroadcastSMS_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Try
        Dim lnard As New MySqlConnection("server = localhost; userid = root; password = 12345; DATABASE = sms;")
        Dim da As MySqlDataAdapter = Nothing
        Dim DT As New DataTable
        Dim sql As String = " "
        sql = "select distinct contactNumber from students" 
        lnard .Open()
        da = New MySqlDataAdapter(sql, lnard)
        da.Fill(DT)

        With combobox1
            .DataSource = DT
            .DisplayMember = "contactNumber "
            .ValueMember = "contactNumber "
        End With
        lnard .Close()
    Catch ex As Exception

    End Try

' 用于发送短信

    Try
        If SerialPort1.IsOpen Then
            SerialPort1.Close()
        End If


        Dim message As String
        '' message = tbUserName.Text
        message = " Notification : " + " " + tbMessage.Text
        SerialPort1.Open()
        If SerialPort1.IsOpen() Then
            SerialPort1.Write("AT" & vbCrLf)
            SerialPort1.Write("AT+CMGF=1" & vbCrLf)
            SerialPort1.Write("AT+CMGS=" & Chr(34) & combobox1.Text & Chr(34) & vbCrLf)
            SerialPort1.Write(message & Chr(26))
            MsgBox("Message Sent")
            SerialPort1.Close()
4

0 回答 0