» SMS from Access | » SMS from C# .NET | » SMS from Visual Basic (VB6) |
» SMS from Excel | » SMS from ASP .NET | » SMS from Visual C++ |
SMS Tutorials >
Sending SMS from VB6 (Visual Basic 6)
- build a new SMS application in Visual Basic (VB6) step-by-step;
- integrate SMS communication into an already existing VB6 application;
- download some ready-to-use SMS source code examples in VB6 and adapt them to your needs.
A minimal expertise on Visual Basic programming is required.
Installing SMSLibX
- Download and install SMSLibX on your PC.
- (Optional) Download and install our VB6 source code examples.
- Connect and install your GSM modem or phone to your PC.
If you don't have a compatible GSM modem/phone, then you can use SMSLibX in simulation mode.
Integrating SMSLibX on VB6
- Open an existent Visual Basic project or create a new one.
- Set up a reference to SMSLibX library (Project > References menu).
If you can't find SMSLibX into the list, please search it with the Browse button. - Open or create a new form or class module, then open its source code (View > Code menu).
Please avoid integrating SMSLibX into common modules (.bas), as they're not able to catch events.
Sending and receiving SMS with VB6
WithEvents
clause is essential in order to catch events raised by the SMSModem object. Using SMSLibX in your IDE
- To display contextual help on a selected SMSLibX item, just click F1.
- To browse SMSLibX library items, please open the Object Viewer (F2) and select SMSLibX library.
- You can use code completion when writing code using SMSLibX objects (Ctrl+SPACE, Ctrl+J etc.)
SMS source code examples in VB6 (Visual Basic 6)
- Example1
Minimal example with SMS sending and event-based SMS receival. - Example2
A complete example showing most SMSLibX features.
This example is in fact the original source code of the SMSLibX Test Utility distributed together with SMSLibX installation.
SMSLibX events and VB6 programming
MsgBox and received SMS messages
Events are not simply delayed but definitively suppressed (please see Microsoft Knowledge Base 76557 article).
A concrete MsgBox re-definition example is available in the source code of the Example2.
Yielding control in your loops
DoEvents
statement in your loop (or time-consuming operaton).Troubleshooting
SMSLibX registration problems
- [...] Cannot find project or library...
- ActiveX component cannot create object...
Other problems with SMSLibX
Download: | vb6_example_for_excel_v1.1.xls |
Download: | vb6_example_for_access_v1.1.mdb |
Download, extract VB6_example.zip and start the project.
On the appeared form provide the following values:
IP address: IP address of Ozeki NG SMS Gateway (127.0.0.1)
Port number: the port number of Ozeki NG SMS Gateway (9501)
Username: the username you use to log into Ozeki NG SMS Gateway (by default it is admin)
Password: the password used in Ozeki NG SMS Gateway (by default it is abc123)
Recipient: the phone number of the recipient (e.g. +36301122334)
Message: the body of the message (e.g. Test Message)
After filling the form click on Send Message (Figure 1).
Figure 1 - Provide values
On Figure 2 you can see the response from Ozeki NG SMS Gateway.
Figure 2 - Response from Ozeki NG SMS Gateway
Figure 3 demonstrates the sent message in Ozeki NG SMS Gateway.
Figure 3 - Sent message in Ozeki NG SMS Gateway
Source code
InternetOpen function creates Internet connection
InternetCloseHandle closes the connection
InternetOpenUrl opens an URL
InternetReadFile saves the HTTP response
SendRequest function requests the URL
Click event of Command1 button will execute the program and write the response XML