We help IT Professionals succeed at work.

AT COMMAND GSM Modem  using USSD    & Vbscript

ultrojo
ultrojo asked
on
25,400 Views
Last Modified: 2011-09-20
Hi EE
I attached the code snipped here:

i try using via Hyperterminal to check balance my prepaid. using ussd at command  *124# and its works  return msg "OK"  then new line " Your Prepaid Balance isxxxxxxxx"

My Problem is when i try to use MSCOMMLib.MSComm from my vbscript file. its not works.
the message only return "OK"

TQ in advance
Sub USSD()
 	Set MSComm1=CreateObject("MSCOMMLib.MSComm")
	MSComm1.Settings = "9600,n,8,1"
	MSComm1.InputLen = 0
	MSComm1.RThreshold = 5
	MSComm1.CommPort = 4
	MSComm1.InBufferCount = 0
	MSComm1.PortOpen = True
	MSComm1.Output="AT+CMGF=1" & vbcrlf
	WScript.Sleep(1000)
 
    TextCommand = "*124#"
    strCommand = "AT+CUSD=1," & Chr(34) & TextCommand & Chr(34) & ",15"
    MSComm1.Output=strCommand				' Send USSD Command
    WScript.Sleep(10000)
    strResponse=MSComm1.Input
 
    If (InStr(strResponse, "OK") > 0) Then             	     ' Response should be OK
        MSComm1.Output=" "
	WScript.Sleep(10000)  	   			 	' Wait for response
       	strResponse2=MSComm1.Input
	
	If (InStr(strResponse2, "+CUSD:") > 0) Then          ' If USSD response is received, display text between ""
            strFields = Split(strResponse2, Chr(34))
            modemReply = strFields(1)
	Else
	    modemReply = "Error strResponse2"
        End If
    ELSE
            modemReply = "Error strResponse"
    End If
 
    MSComm1.PortOpen = False
   set MSComm1=nothing
    
End Sub
 
Call USSD()
msgbox modemReply

Open in new window

Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.