I am developing a sms bulk sender using smart bro plug in modem.
when I am sending, it gives an error of Message sending failed. This is my code.
With Serialport1
.Write("AT" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write(AT+CMGF=1" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write("AT+CMGS=1" & Chr(34) & txtNumber.Text & Chr(34) & vbCrLf)
.Write(RichTextBox.text & Chr(26))
Threading.Thread.Sleep(1000)
MsgBox(rcvdata.ToString)
When I use Putty to check the connection of the modem; these are the results
AT
ok
AT+CMGF=1
Ok
'when I tried
AT+CMGS="+639970850099"
Error
Requesting someone who can help me.
Thank you and keep safe.
.Write("AT+CMGS=1" & Chr(34) & txtNumber.Text & Chr(34) & vbCrLf)
No 1 sa AT+CMGS=
Should be
.Write("AT+CMGS=" & Chr(34) & txtNumber.Text & Chr(34) & vbCrLf)
Related
When using InputBox in Visual Basic 6 can I input a multiline string?
strSrch = InputBox("Enter word(s) or phrase(s), like " & Chr(34) & "Jesus wept" & _
Chr(34) & " to search for any word or phrase" & vbCrLf & _
"If you place & between words the verse must contain both words, loved & world" & _
vbCrLf & "or both phrases, " & Chr(34) & "keep the commandments" & Chr(34) & _
" & " & Chr(34) & "of Jesus" & Chr(34) & vbCrLf & "Put ! in front of a word or phrase to exclude it from your search, Jesus ! testimony" & _
vbCrLf & "Use( before and ) after expressions to group them together, (" & Chr(34) & _
"Come unto me" & Chr(34) & " & all)" & vbCrLf & "Use Xor between two words to include one or the other but not both, " & _
Chr(34) & "I am" & Chr(34) & " Xor that", "Word Search")
No, not really. IIRC, the InputBox should preserve any newline chars that are dropped into it via a paste or entered via ALT+###. But, they will appear as spaces in the box.
It will only ever appear on a single line. There's no real way to use an InputBox to let a user enter multiple lines.
The most feature-capable way to handle this would be to create a custom form and use it to collect user input. You can make it a modal dialog to force the user to interact with it, similar to an InputBox. There are a few ways to pass the input back to the procedure that displayed the form (such as using a global variable).
I want to assign below mentioned xml values to a string like this
Dim test As String
test = ... ?
Where the XML should contain:
<RptVer>1</RptVer>
<RptTyp>1</RptTyp>
</RptInfo>
</InstRptRoot>
How can I do this and also preserve the formatting (ie linebreaks, spacing, etc.)?
Mark answered your question, I'll answer your second question:
Dim test As String
test = "<RptInfo>" & vbCrLf & vbCrLf & _
vbTab & "<RptVer>1</RptVer>" & vbCrLf & vbCrLf & _
vbTab & "<RptTyp>1</RptTyp> & vbCrLf & vbCrLf & _
"</RptInfo>"
Assuming you want it double-spaced and indented. You had also missed the leading tag, but MarkL caught that as well.
I'm new to Vb6. I just want to know how to use my sms code to send all the numbers in the rows in a specific column. In this code, the messages i received are more than what i want to receive. Please help me fix my looping method.
Dim x As String
Dim e As Integer
Dim allcontacts As String
For i = 0 To DataGrid1.VisibleRows
For e = 0 To DataGrid1.ApproxCount - 1
allcontacts = DataGrid1.Columns(5).CellValue(DataGrid1.GetBookmark(e))
' Send an 'AT' command to the phone
MSComm1.Output = "AT" & vbCrLf
Sleep 500
MSComm1.Output = "AT+CMGF=1" & vbCrLf 'This line can be removed if your modem will always be in Text Mode...
Sleep 500
MSComm1.Output = "AT+CMGS=" & Chr(34) & allcontacts & Chr(34) & vbCrLf 'Replace this with your mobile Phone's No.
Sleep 1000
MSComm1.Output = "From School Activities Management System: " & vbCrLf & vbCrLf & "The time now is " & Label3.Caption & vbCrLf & vbCrLf & "Announcement:" & vbCrLf & Text1.Text & Chr(26)
Sleep 2000
Next e
Next i
x = DataGrid1.VisibleRows
MsgBox "Message Sent to " + x + " contacts in faculty."
End Sub
Here's a screenshot of the datagrid:
Based upon your screenshot, it looks like you want to send 1 sms for each row. Therefore, I would try the following code:
Dim i As Integer
Dim allcontacts As String
For i = 0 To DataGrid1.VisibleRows - 1
allcontacts = DataGrid1.Columns(5).CellValue(DataGrid1.GetBookmark(i))
' Send an 'AT' command to the phone
MSComm1.Output = "AT" & vbCrLf
Sleep 500
MSComm1.Output = "AT+CMGF=1" & vbCrLf 'This line can be removed if your modem will always be in Text Mode...
Sleep 500
MSComm1.Output = "AT+CMGS=" & Chr(34) & allcontacts & Chr(34) & vbCrLf 'Replace this with your mobile Phone's No.
Sleep 1000
MSComm1.Output = "From School Activities Management System: " & vbCrLf & vbCrLf & "The time now is " & Label3.Caption & vbCrLf & vbCrLf & "Announcement:" & vbCrLf & Text1.Text & Chr(26)
Sleep 2000
Next i
MsgBox "Message Sent to " & DataGrid1.VisibleRows & " contacts in faculty."
One thing to keep in mind is that messages will only be sent for those rows that are visible on the screen. If they are scrolled off the screen and can't be seen then no message will be sent.
I'm running a script that performs multiple checks on a Windows machine before running a program. I'm running a VBScript script that checks things such as patch status, firewall status, and antivirus software status. After the script runs, the information needs to be output so the end user can fix any issues that arise. This needs to be output in a single message box that shows everything that is not compliant on the end users machine.
Right now after the script runs I'm getting multiple boxes for output, and none of them are displaying the names of what needs to be fixed. I'm just getting the information in quotes in the dialog box.
errors = Array(strSUpdate,strFirewallStatus,strProdState)
Dim errorfix
For Each item In errors
set errorfix = errorfix & item & vbnewline
if (errors = "Off") Then
msgbox "Compliance Check results" & vbNewLine & vbNewLine & _
"The following requires attention" & vbNewLine & errorfix & vbNewLine & _
"Press OK to Continue", 0, "Moka 5 Compliance Check"
Else
msgbox "Compliance Check results" & vbNewLine & vbNewLine & _
"Everything looks good." & vbNewLine & vbNewLine & _
"Press OK to Continue", 0, "Moka 5 Compliance Check"
End if
Next
My suggestion is to avoid arrays altogether and use the much more convenient dictionaries instead.
If nothing else you will create much more readable code that way, but they are also a lot more powerful than arrays.
Option Explicit
Dim errors
Set errors = CreateObject("Scripting.Dictionary")
' fill the dictionary troughout your program. Fill in just the
' actionables and don't insert the stuff that's okay.
errors("Firewall Status") = "Off"
errors("This other thing") = "Missing"
If errors.Count = 0 Then
MsgBox "Compliance Check results" & vbNewLine & vbNewLine & _
"Everything looks good." & vbNewLine & vbNewLine & _
"Press OK to Continue", vbOkOnly, "Moka 5 Compliance Check"
Else
Dim item, toFix
For Each item In errors
toFix = toFix & " - " & item & " is " & errors(item) & vbNewLine
Next
Msgbox "Compliance Check results" & vbNewLine & vbNewLine & _
"The following requires attention:" & vbNewLine & _
toFix & vbNewLine & _
"Press OK to Continue", 0, "Moka 5 Compliance Check"
End If
I think you need to get the return value from the msgbox, i.e., tempresponse = Msgbox(""). The link is here
errors = Array(strSUpdate,strFirewallStatus,strProdState)
Dim errorfix, tempresponse
For Each item In errors
set errorfix = errorfix & item & vbnewline
if (errors = "Off") Then
tempresponse = msgbox ("Compliance Check results" & vbNewLine & vbNewLine & _
"The following requires attention" & vbNewLine & errorfix & vbNewLine & _
"Press OK to Continue", 0, "Moka 5 Compliance Check")
Else
tempresponse = msgbox ("Compliance Check results" & vbNewLine & vbNewLine & _
"Everything looks good." & vbNewLine & vbNewLine & _
"Press OK to Continue", 0, "Moka 5 Compliance Check")
End if
Next
As #Tomalak has said, after each iteration you will need to clear the msgbox. Would a popup work better, as it will clear the message after x seconds.
i am creating a .vbs file that should open access, and inside access a form call "Issue Details", but passing a parameter, meaning that if i have 10 issues in my "Issues" table a vbs file is created for each one and when clicked should open the right record(would be one ID for each record in the table). It is so far opening access and it is opening the form(Issue Details) but it is blank. What am i missing? Help, getting crazy here ... Check code below. The weird thing here is that if i double click it again it will refresh and open the right record without opening anymore windows..
How can i fix that? I dont want to do it twice :)
Public Sub sendMRBmail(mrbid)
DoCmd.OpenForm "Issue Details", , , "[ID] = " & mrbid
End Sub
Private Sub Create_Click()
On Error GoTo Err_Command48_Click
Dim snid As Integer
snid = Me.ID
Dim filename As String
filename = "S:\Quality Control\vbs\QC" & snid & ".vbs"
Dim proc As String
proc = Chr(34) & "sendMRBmail" & Chr(34)
Dim strList As String
strList = "On Error Resume Next" & vbNewLine
strList = strList & "dim accessApp" & vbNewLine
strList = strList & "set accessApp = createObject(" & Chr(34) & "Access.Application" & Chr (34)")" & vbNewLine
strList = strList & "accessApp.OpenCurrentDataBase(" & Chr(34) & "S:\Quality Control\Quality DB\Quality Database.accdb" & Chr(34) & ")" & vbNewLine
strList = strList & "accessApp.Run " & proc & "," & Chr(34) & snid & Chr(34) & vbNewLine
strList = strList & "set accessApp = nothing" & vbNewLine
Open filename For Output As #1
Print #1, strList
Close #1
Err_Command48_Click:
If Err.Number <> 0 Then
MsgBox "Email Error #: " & Err.Number & ", " & "Description: " & Err.Description
Exit Sub
End If
End Sub
Found the problem. Changed instruction below, adding acFormEdit to it and it worked:
DoCmd.OpenForm "Issue Details", , , "[ID] = " & mrbid, acFormEdit