0% found this document useful (0 votes)
698 views6 pages

Send An SMS Text Message Through A COM - USB GSM Modem Using Visual Basic For Applications

SMS VB

Uploaded by

edz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
698 views6 pages

Send An SMS Text Message Through A COM - USB GSM Modem Using Visual Basic For Applications

SMS VB

Uploaded by

edz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

10/24/2016 SendanSMStextmessagethroughaCOM/USBGSMmodemusingVisualBasicforApplications

ShortcutMenu

Products
Partners
Contactus

ActiveXperts

Skip

MainNavigation

Home
Products
ActiveXpertsNetworkMonitor
ActiveXpertsSMSMessagingServer
ActiveXpertsSMSComponent
ActiveXpertsNetworkComponent
ActiveXpertsEmailComponent
ActiveXpertsSerialPortComponent
ActiveXpertsHydromagic
ActiveXpertsFreewareUtilities
Downloads
Purchase
Pricing
Ordering
FindaReseller
ResellerArea
ContactSales
Support
TechnicalSupport
KnowledgeBase
ContactSupport
Company
Contactus
NewsItems
PressReleases
Sitemap
Freeware

Chooseyourlanguage

English
Espanol
Portuguese
Italiano
Deutsch
Dansk
Nederlands

ActiveXperts
SMSComponent

Home
DownloadTrial(.exe)
Screenshots
SupportedSMSProtocols
SupportedGSMModems
Licensing
Ordernow
ReleaseNotes
Support

ProductNavigation

ActiveXpertsNetworkMonitor
ActiveXpertsSMSMsgServer
ActiveXpertsSMSComponent
ActiveXpertsNetworkComp.
ActiveXpertsEmailComponent
ActiveXpertsSerialPortComp.
ActiveXpertsHydromagic
ActiveXpertsFreewareUtilities
http://www.activexperts.com/smscomponent/howto/gsmsend/vba/ 1/6
10/24/2016 SendanSMStextmessagethroughaCOM/USBGSMmodemusingVisualBasicforApplications
Purchase

Pricing
Licensing
OrderNow

RelatedDocuments

OnlineSamples
DigitallySignComponent
DistributeComponent
ATcommands
SMPPSpecifications3.4
GSMErrorCodes
GSMNetworkCodes
MobileCommunications
TAP/UCPProviders
SMSProtocolDocuments
TAPI

Providers

SMPPProviders
TAP/UCPProviders
SNPPProviders

Support

KnowledgeBase/FAQ
ContactSupport

Youarehere:

ActiveXperts.com>SMSComponent>HowtoUsetheActiveXpertsSMSComponent>GSMmodemsend>VisualBasicfor
Applications

AddSMScapabilitiestoanyWindowsor
.NETapplication

Quicklinks

DownloadActiveXpertsSMSComponent6.4(Windowsx64,Windowsx86)
ViewManual(HTML)
ScreenshotsProductimagegallery

VisualBasicforApplicationssampleSendSMStextthrougha
COM/USBGSMmodem
TheActiveXpertsSMSComponentisasoftwaredevelopmentkit(SDK)toenhanceanapplicationorscriptwithSMSorPagerfunctionality.
SMSmessagescanbesent/receivedusingaGSMmodem,anSMPPprovideroranHTTPcompliantSMSC.

Introduction
InthisexamplewearegoingtocreateaVisualBasicforApplicationsscripttosendSMSmessages.Thisdemoprojectwillasktheuserto
giveaphonenumberandamessagebodyonthecommandprompt.AGSMmodemisrequiredforthisdemo.

Step1:DownloadandinstalltheActiveXpertsSMSComponent
DownloadtheActiveXpertsSMSComponentfromtheActiveXpertsDownloadSiteandstarttheinstallation.Theinstallationguidesyou
throughtheinstallationprocess.

Step2:CreateanewExceldocument
Createtheformdisplayedintheimagebelow.Tocreatethebuttons,textarea'sanddropdownmenu's,click"View","Toolbars","Control
toolbox".

http://www.activexperts.com/smscomponent/howto/gsmsend/vba/ 2/6
10/24/2016 SendanSMStextmessagethroughaCOM/USBGSMmodemusingVisualBasicforApplications

(Clickonthepicturetoenlarge)

Step3:Fillinthedropdownmenu's
Inthissample,we'recreatingaformthatisabletosendanSMSinMicrosoftExcel.SendinganSMSwithourSMSComponentcanbe
doneinjustafewlinesofcode.ThecoreofthislittlesystemistheGsmobjectwitchisthefirstlineofcodethatmustbetypeddowninyour
code.Afterthat,justaddthephonenumber,themessage,tellthesystemwhatportthedeviceisconnectedtoandeventuallysendthe
message.

Youcanconfigurealotofextraoptions.Fewofthemareusedinthissample.Moreinformationaboutthoseoptionsaretobefoundinthe
productsmanualwhitchisshippedwithourproduct.Inthissampleweareconfiguringalogfile,themessagetype,wearecheckingthe
statusoftheSMS(Whetherithasbeensentornot)andwe'redisplayingthemodemsconnectedtothecomputer.

Inthissampleweworkwithforms.Itispossibletoworkwithjustthefieldstoo.TocreateanexcelfilewhitchisabletosendanSMS,firstof
all,createanewexcelfilewiththeformthatisdisplayedbelowinit.

(Clickonthepicturetoenlarge)

Alotofthingsinthisformareoptional.Basicallyyouonlyneedthefieldsmentionedbelow:

Thedevicefield
Thepincodefield
Therecipientfield
Themessage

Makesureyoudon'tforgettocreateasubmitbutton.

http://www.activexperts.com/smscomponent/howto/gsmsend/vba/ 3/6
10/24/2016 SendanSMStextmessagethroughaCOM/USBGSMmodemusingVisualBasicforApplications
ThefirstandmostimportantthingistocreatetheActiveXpertsobjects.Todothatmeansweneedtotypesomecode.Youcanaddcodeto
anexcelsheet.Click"View","Toolbars"andthen"ControlToolbox".Youwillseea"DesignMode"icon( ),clickit.Doubleclickthesubmit
buttonyoucreatedinyourform.TheMicroSoftVisualBasicEditorwillnowbeopened.Youcantypeallcodehere.

TheActiveXpertsobjectshavetobepublicvariablesbecausetheyareusedindifferentsubs.Usethefollowingcodeforthat.
'Declaretheobjectvariables
PublicobjGsmAsObject
PublicobjSmsMessageAsObject
PublicobjSmsConstantsAsObject

TofillthesevariableswiththeActiveXpertsSoftware,we'recreatingafunctionsoinanysituationwe'resuretheobjectisloadedproperly.
Usethefollowingcode:
DimobjGsm,objMessage,objConstants

SetobjGsm=CreateObject("AxSms.Gsm")
SetobjMessage=CreateObject("AxSms.Message")
SetobjSmsConstants=CreateObject("AxSms.Constants")

InthesamplewecreatedaseperatesubforsendingtheSMS.Ifthesubmitbuttonisclickedfistacheckispreformed.Ifthephonenumber
iscorrecttheSMSwillbesent.Theobjectswe'vecreatedworkwiththeActiveXpertsSMSComponent.Everypropertyofthe
toolkit/componentcanusedwithadot.Everyobjecthasitsownpropertieswhitchcanbefoundintheproductsmanualthatisshippedwith
theproduct.Hereisanexampleofhowtocalltoaproperty.ThisscriptwilprinttheversionoftheActiveXpertsSMSComponent'sversionin
amessagebox.
Subcreateobjects()
DimobjGsmasObject
SetobjGsm=CreateObject("AxSms.Gsm")

msgbox(objGsm.Version)
EndSub

TosendtheSMSweneedtocollecttheinformationenteredtheuseranduseittosendtheSMS.Whenyou'rewritingyourscriptmakesure
thescriptstopsifanycommandhasnotexecutedproperly.Youareabletocheckthisusingthe"LastError"propertyinour
toolkit/component.Hereisanexamplewhatyoucouldmakeyourscriptlooklike.

Step5:SendSMSmessage
ThefollowingcodeshowshowtosendanSMSmessageusingthedatathatwasstoredinthe'objSmsMessage'and'objSmsConstants'
objects.

Appendix:Fullsourcecode
FollowingyoucanfindthefullsourcecodewhichisalsoincludedintheActiveXpertsSMSComponentpackage.

PrivateSubWorkbook_Open()

EndSub
PrivateSubcmdSubmit_Click()

'Getthesubmittedinfo
DimstrServer,strPort,strSystemID,strPassword,strSystemType,strRecipient,strMessage,numTimeout

strServer=Cells(5,2)
strPort=Cells(6,2)
strSystemID=Cells(7,2)
strPassword=Cells(8,2)
strSystemType=Cells(9,2)
strRecipient=Cells(10,2)
strMessage=Cells(11,2)

'Creatingtheobjects
DimobjSmpp,objMessage,objConstants

SetobjSmpp=CreateObject("AxSms.Smpp")
SetobjMessage=CreateObject("AxSms.Message")
SetobjSmsConstants=CreateObject("AxSms.Constants")

'Setsomeproperties
objSmpp.Clear

numTimeout=5000

'Connect
objSmpp.ConnectstrServer,CInt(strPort),numTimeout
numLastError=objSmpp.LastError
http://www.activexperts.com/smscomponent/howto/gsmsend/vba/ 4/6
10/24/2016 SendanSMStextmessagethroughaCOM/USBGSMmodemusingVisualBasicforApplications

If(objSmpp.LastError=0)Then

objSmpp.BindobjSmsConstants.SMPP_BIND_TRANSCEIVER,strSystemID,strPassword,"",objSmsConstants.SMPP_VERSION_34,0,0,"",numTimeout
numLastError=objSmpp.LastError

If(objSmpp.LastError=0)Then

'Message:setallproperties
objMessage.Clear
objMessage.ToAddress=strRecipient
objMessage.Body=strMessage
objMessage.BodyFormat=objSmsConstants.BODYFORMAT_TEXT

objSmpp.SubmitSms(objMessage)
numLastError=objSmpp.LastError

objSmpp.Unbind
EndIf

objSmpp.Disconnect
EndIf

Cells(17,2)=CStr(numLastError)&":"&objSmpp.GetErrorDescription(numLastError)

SetobjSmpp=Nothing
SetobjMessage=Nothing
SetobjConstants=Nothing

EndSub

YoucandownloadthefullsourcecodeofthisprojectfromtheActiveXpertsFTPsite:ftp.activexpertslabs.com/samples/smscomponent.
TherearemanyotherworkingsamplesincludedwiththeproductorontheFTPsite.

NOTE:DemoProjectsarecreatedwithMicrosoftVisualStudio2008
TheActiveXpertsSMSComponentprojectshipswithasetofMicrosoftVisualStudio.NETsamples.TheprojectsarecreatedwithMicrosoft
VisualStudio2008.

UserswithalaterversionofMicrosoftVisualStudiocanopensuchaproject.TheVisualStudioConversionWizardwillguideyouthrough
theprocessofconvertingtheprojecttotheversionused.

Facebook
GooglePlus
Twitter
YouTube
LinkedIn

Products
NetworkMonitor
SMSMessagingServer
SMSComponent
NetworkComponent
SerialPortComponent
EmailComponent
Hydromagic
FreewareUtilities

Resources
AdministratorTools
SMPPProviders
Modems

Support
Knowledgebase
Technicalsupport

Sales
http://www.activexperts.com/smscomponent/howto/gsmsend/vba/ 5/6
10/24/2016 SendanSMStextmessagethroughaCOM/USBGSMmodemusingVisualBasicforApplications
Licenseinformation
Purchase

SiteMap
ContactUs
TermsofUse
PrivacyPolicy
Copyright2016ActiveXpertsSoftwareB.V.Allrightsreserved.

http://www.activexperts.com/smscomponent/howto/gsmsend/vba/ 6/6

You might also like