How to send multiple mobile # in vb6 using AT command - gsm

hi guys i develop an application in vb6.0 sending to mobile # is fine but when i try to send two or more mobile # it will only send to the first # and the other is none. here is my code please take a look.
MSComm1.Output = "AT" & vbCrLf
Sleep 100
MSComm1.Output = "AT+CMGF=1" & vbCrLf
Sleep 200
MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpM_MobileNum & Chr(34) & vbCrLf
Sleep 300
MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpF_MobileNum & Chr(34) & vbCrLf
Sleep 400
MSComm1.Output = TMPMESEJ & Chr(26) & vbCrLf
Sleep 500
i hope you can help me at this.
Thank you

To send an SMS via a modem you are correct in using the AT+CMGS but I believe you are not following the syntax of the command correctly.
You need to send the following:
AT+CMGS=<Mobile phone number><cr>
<Message text><ctrl-Z>
You can only send one message at a time to one mobile phone number. And from what I can see your code is attempting to send multiple messages before trying to send the <ctrl-Z>
By the way is ascii character 26.
////////////////////////////////////////
// Send message to first mobile number
////////////////////////////////////////
MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpM_MobileNum & Chr(34) & vbCrLf
// Wait for answer from modem should return ">"
MSComm1.Output = "Test Message One" & Chr(26)
// Wait for answer to check if OK came back
////////////////////////////////////////
// Send message to second mobile number
////////////////////////////////////////
MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpF_MobileNum & Chr(34) & vbCrLf
// Wait for answer from modem should return ">"
MSComm1.Output = "Test Message Two" & Chr(26)
// Wait for answer to check if OK came back

Related

Exporting Json data in asp.net vb from MS SQL

I am trying to export data from MS SQL out in a json format in my asp.net web forms application. Problem is it exports with two double quotes around the values instead of just one double quote.
I want it to export like this:
{"bizunitid":"11111","prodlineid":"1","reasonforsurvey":"1"}
but it is coming out like this:
"{""bizunitid"":""11111"",""prodlineid"":""1"",""reasonforsurvey"":""2""}"
I have tried replacing the two double quotes but it always returns two double quotes.
Dim json As String = cmd.ExecuteScalar
streamWriter.Write(json.Replace("""""", Chr(34)))
Not sure if this is what you're looking for, but it's how I've done it when posting JSon to an API for a messaging app with VB.Net:
MessageTitle = MessageTitle.Replace("""", """""")
MessageBody = MessageBody.Replace("""", """""")
Dim strPostData As String = "{" &
"""notification"": {" &
"""sound"": ""default""," &
"""title"": """ & MessageTitle & """," &
"""body"": """ & MessageBody & """" &
"}, " &
"""data"": {" &
"""title"": """ & MessageTitle & """," &
"""body"": """ & MessageBody & """" &
"}," &
"""to"": """ & strRegIDs & """," &
"""priority"": 10 " &
"}"
hopefully that helps a bit

How to get handle of the most recently opened window autoit?

I am trying to automate testing of an application. When opening the application it might open a pop-up window or security alert and I want to handle it. So is there a way to get handle or title of the most recently opened window in AutoIt?
Maybe you need to add some options. WinSearchChildren ...
include
Example()
Func Example()
; Retrieve the window title of the active window.
Local $sText = WinGetTitle("[ACTIVE]")
; Display the window title.
MsgBox($MB_SYSTEMMODAL, "", $sText)
EndFunc ;==>Example
I ran into this issue when needing to see a window "flash" every 60 seconds something was grabbing the focus, then changing back to the original window. I was able to write the following and capture the hi-jacker.
;what is the current active window
$Win1 = ""
$Win2 = ""
$Win3 = ""
$Win4 = ""
$Win5 = ""
$Win6 = ""
HotKeySet("{F1}","myExit")
while(1)
$blah = WinGetTitle("[ACTIVE]")
if $blah <> $Win1 Then
$Win6 = $Win5
$Win5 = $Win4
$Win4 = $Win3
$Win3 = $Win2
$Win2 = $Win1
$Win1 = $blah
EndIf
ToolTip("Last Active Windows: [press F1 to quit]" & #CRLF & "-" & $Win1 & #CRLF & "-" & $Win2 & #CRLF & "-" & $Win3 & #CRLF & "-" & $Win4 & #CRLF & "-" & $Win5 & #CRLF & "-" & $Win6)
sleep(100)
WEnd
Func myExit()
msgbox(0,"closing","closing program")
Exit
EndFunc

ASP.Net Environment.NewLine stops working half way through a script?

I'm using a script to construct an email, and half way through the NewLines just quit working. I don't see any errors, nor do I can any when it's executed.
Here is the code:
message = message & "Zoning Selections -" & Environment.NewLine & Environment.NewLine
message = message & "Standard Report: " & Request.QueryString("chkList0") & Environment.NewLine
message = message & "Summary Zoning Report: " & Request.QueryString("chkList1") & Environment.NewLine
message = message & "Executive Summary: " & Request.QueryString("chkList2") & Environment.NewLine
message = message & "ZIP Report: " & Request.QueryString("chkList3") & Environment.NewLine
message = message & "Custom Report - Individual Products: " & Request.QueryString("chkList4") & Environment.NewLine
message = message & "Certificate of Occupancy: " & Request.QueryString("chkList5") & Environment.NewLine
message = message & "Building Code Violation: " & Request.QueryString("chkList6") & Environment.NewLine
message = message & "Code Compliance Violation: " & Request.QueryString("chkList7") & Environment.NewLine
message = message & "Fire Code Violation: " & Request.QueryString("chkList8") & Environment.NewLine
message = message & "Saftey Code Violation: " & Request.QueryString("chkList9") & Environment.NewLine
message = message & "Condemnation Report: " & Request.QueryString("chkList10") & Environment.NewLine
message = message & "Property Use: " & Request.QueryString("property_use") & Environment.NewLine
and here is the output:
Zoning Selections -
Standard Report: yes
Summary Zoning Report: yes
Executive Summary: yes
ZIP Report: yes
Custom Report - Individual Products: yes Certificate of Occupancy: yes Building Code Violation: yes Code Compliance Violation: yes Fire Code Violation: yes Saftey Code Violation: yes Condemnation Report: yes Property Use: Office
As you can see, the NewLine works until half way through, and then it simply prints everything on the same line. (also, the other NewLines were added to the file at another time than the ones printing correctly)
What am I missing?
EDIT
Apparently the plain-text formating of an email break all Environment.NewLine line breaks for the rest of the email when it encounters a line longer than 40-50 character (I was using Outlook 2013).
My solution was simple, switch to HTML format and use tags for line breaks instead.

SMS HTTP API call from ASP.NET is slow

For a web application, I am creating a SMS module that can send an SMS from the application. My SMS provider has an API that I can call over HTTP.
The API is called via an XmlTextReader who just reads the XML response from the API.
Now my problem is: When I send the SMS from a web page (basically just doing an HTTP request) it takes more than a minute before I receive the SMS.
But when I run the exact same code from a Windows console application, my SMS arrives in less then 5 seconds.
I have done multiple tests with this, and it's not really my SMS provider who is slow.
Somehow, the HTTP request gets delayed from within the ASP.NET engine, and it does not delay directly from an console application. Is there a solution?
This is the way I'm calling the HTTP API:
Dim strPostString As String = Convert.ToString(muriPostUrl) & mstrPostPath
If mblnUseSecureConnection Then
strPostString = Convert.ToString(muriSecurePostUrl) & mstrPostPath
End If
Dim strDataString As String = "username=" & mstrUsername
strDataString += "&" & "password=" & mstrPassword
strDataString += "&" & "originator=" & mstrOriginator
strDataString += "&" & "recipients=" & mstrRecipients
strDataString += "&" & "gateway=" & mstrGateway
strDataString += "&" & "reference=" & mstrReference
strDataString += "&" & "message=" & mstrMessage
If mstrType <> String.Empty Then
strDataString += "&" & "type=" & mstrType
End If
If mstrUDH <> String.Empty Then
strDataString += "&" & "udh=" & mstrUDH
End If
If Not mdtDeliveryDate = Nothing Then
Dim objDeliveryDate As New StringBuilder()
objDeliveryDate.Append(mdtDeliveryDate.Year)
objDeliveryDate.Append(Prefix(mdtDeliveryDate.Month.ToString(), 2))
objDeliveryDate.Append(Prefix(mdtDeliveryDate.Day.ToString(), 2))
objDeliveryDate.Append(Prefix(mdtDeliveryDate.Hour.ToString(), 2))
objDeliveryDate.Append(Prefix(mdtDeliveryDate.Minute.ToString(), 2))
objDeliveryDate.Append(Prefix(mdtDeliveryDate.Second.ToString(), 2))
strDataString += "&" & "deliverydate=" & Convert.ToString(objDeliveryDate)
End If
Dim strReturnValue As String = ""
Dim xmlReader As New XmlTextReader(String.Format("{0}?{1}", strPostString, strDataString))
While xmlReader.Read()
If xmlReader.NodeType = XmlNodeType.Element Then
Select Case xmlReader.LocalName
Case "recipients"
If True Then
mintSuccessCount = Integer.Parse(xmlReader.ReadString())
strReturnValue += "recipients : " & mintSuccessCount.ToString() & vbCr & vbLf
Exit Select
End If
Case "success"
If True Then
mblnSuccess = Boolean.Parse(xmlReader.ReadString())
strReturnValue += "success : " & mblnSuccess.ToString() & vbCr & vbLf
Exit Select
End If
Case "resultcode"
If True Then
mintResultCode = Integer.Parse(xmlReader.ReadString())
strReturnValue += "resultcode : " & mintResultCode.ToString() & vbCr & vbLf
Exit Select
End If
Case "resultmessage"
If True Then
mstrResultMessage = xmlReader.ReadString()
strReturnValue += "resultmessage : " & mstrResultMessage & vbCr & vbLf
Exit Select
End If
End Select
End If
End While
Also, when performing an HTTP request from ASP.NET, it does not appear in Fiddler, while the actual HTTP request happens. How can I track the HTTP fastback from within the ASP.NET engine?
I still don't know what the problem is, but I worked around it by doing the postback via an HttpWebRequest directly. I think the problem was somewhere in the while loop.

How to Validate a textbox+dropdowns in vb for a asp.net form

Previous question which links onto this and has any addition code ref should I forget to link any, I have set it up to email me should someone submit this form and an error occur and right now should that occur for most integer or datetime fields if they fail to validate then it will show me which fields in the email failed and what was input into them.
Problem I'm having now is to validate the drop downs and the textboxs in a similar way to what I with integer and datetime fields so I can display those also in the email in case they error.
present integer and datetime validation
Catch ex As Exception
lblInformation.Text = ("<h4>Unable to save data in database</h4>" + vbNewLine + "The error was '" + ex.Message + "'" + vbNewLine + vbNewLine + vbNewLine + "The SQL Command which falied was:" + vbNewLine + "<strong>" + mySQL + "</strong>" + vbNewLine).Replace(vbNewLine, "<br />" + vbNewLine)
Dim dtb As DateTime
If Not DateTime.TryParse(DateOfBirth, dtb) Then
strEMessageBody.Append("<strong>Date Of Birth:</strong> " & DateOfBirthYear.SelectedItem.Value & "-" & DateOfBirthMonth.SelectedItem.Value & "-" & DateOfBirthDay.SelectedItem.Value & vbCrLf)
strEMessageBody.Append("<br/>" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab)
End If
Dim iao As Integer
If Not Integer.TryParse(AnyOther, iao) Then
strEMessageBody.Append("<strong>Any Other:</strong> " & rblAnyOther.Text & vbCrLf)
strEMessageBody.Append("<br/>" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab)
End If
then below the final validation I have the Dim for the email setting but that I sorted out in the other question.
The problem is much earlier in the page I have
Sub Upload_Click(ByVal source As Object, ByVal e As EventArgs)
If (Page.IsValid) Then
Dim Name As String
Which prevents me just using there names as shown above where I would instead call them something else but that doesn't work with strings so my main issue is having some bit of code to check if the strings are valid and for the dropdowns which would either work but always show the data in the email or would hiccup in the code,
Dim imd As Integer
If Not Integer.TryParse(dept, imd) Then
strEMessageBody.Append("<strong>Department:</strong> " & dept.Text & vbCrLf)
strEMessageBody.Append("<br/>" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab)
End If
below was how it had been setup to record the department
Department = dept.SelectedItem.Value
Department = Replace(Department, "'", "''")
Summary:- Need vb code to validate if strings and dropdowns are valid and the use of try/catch block is another possible solution but I wasn't able to figure out how to implement validation for that either.
Log your values into your database. Setup a logging table called "tblLog" or something else. Record the value of ex.Message or possibly even InnerException (if it exists).
Going hand in hand with Matt's answer, there is a tool that can help you with automatically logging errors to a DB.
It's called ELMAH.
EDIT
Here are 2 validations that you might want to use:
Dim s As String = "some user input in here"
If [String].IsNullOrEmpty(s) Then
' Watch out, string is null or it is an empty string
End If
Dim cb As New ComboBox()
If cb.SelectedItem Is Nothing Then
' Watch out, combo has no item selected
End If
NOTE ComboBox is a WinForm control in this example, but the idea is the same for the ASP.NET counterpart
Since everybodies given up trying to find a solution then I'm just gona close this topic with this post as the answer.

Resources