Click here to Skip to main content
15,309,875 members
Articles / Programming Languages / Visual Basic
Posted 27 Oct 2004


14 bookmarked

IBM Messenger in VB.NET

Rate me:
Please Sign up or sign in to vote.
3.42/5 (8 votes)
27 Oct 20041 min read
IBM Messenger in VB.NET.

Image 1


Imagine if you could send a message to an AS400 (or I5) machine, by using a neat and small program that gives you a lot of power on messaging.

How it works

This program uses a “Stored Procedure” in AS400 (or I5) to send a message to another user, or all the users. All you need to do is to type the message, choose the recipients, and hit the “SEND” button. You are allowed to save the message, or retrieve a message to be sent. Adding new recipient is as easy as filling in an input box! All together, this program is very easy to use and straightforward.

Something about the code

  1. Here is the main trick that uses the Stored Procedure (SNDMSG):
    "CALL QSYS.QCMDEXC('" & StrCom & "'," & ParameterL & ")"

    CALL QSYS.QCMDEXC() is a function that lets you run a procedure in AS400 (or I5). This function accepts two parameters:

    1. Procedure name
    2. Procedure length

    The following is the made up procedure:

    "SNDMSG MSG('" & Messagetxt & "') TOUSR(" & Recepient & ")"

    The variable ParameterL keeps the length of the procedure and its parameters. Once you make up the procedure, then the CALL QSYS.QCMDEXC() would execute it. However, setting up a procedure and an accurate length for the procedure and its parameters are crucial.

  2. The second trick in the program is an “embedded .wav file”. Once you click on the “SEND” button, it sends the message and runs an embedded .wav file.

    'Play Sound
    Private Declare Function PlaySound Lib "winmm.dll" (ByVal data() As Byte, _
          ByVal hMod As IntPtr, ByVal hwFlags As Integer) As Integer
     Private Const SND_ASYNC As Integer = &H1        'Play asynchronously
     Private Const SND_MEMORY As Integer = &H4       'Play wav in memory
     'The .wav will be stored in this byte array
     Private Shared ClickSound As Byte()
     Shared Sub New()
      'Get running assembly name
      Dim NameSpc As String = _
      'Look for the button click sound in the resource stream.
      Dim SoundFile As String
      Dim WavStrm As IO.Stream = _
       Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
       NameSpc + "." + "DRIVEBY.WAV")
      'ReDim the byte array to be the size of the embedded .wav
      ReDim ClickSound(CType(WavStrm.Length, Integer))
      'Load the .wav from the stream into the byte array
      WavStrm.Read(ClickSound, 0, Int(CType(WavStrm.Length, Integer)))
     End Sub
     'Override the OnClick event to play the sound
     '  Protected Overrides Sub OnClick(ByVal ea As EventArgs)
     '  Call PlayWav(ClickSound)
     '  MyBase.OnClick(ea)
     ' End Sub
     'Play embedded .wav resource
     Public Sub PlayWav(ByVal WavResource As Byte())
      PlaySound(WavResource, IntPtr.Zero, SND_ASYNC Or SND_MEMORY)
     End Sub


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Kourosh K Tari
Chief Technology Officer
United States United States
I sold my beloved racing bicycle to buy my first computer, a Sinclair home computer! That was over 30 years ago and I am still in love with what became my profession, and quite honestly my calling! I have received my BS and MS in Mathematics and Computer science and have been working in so many fields of software development, system architecture, and design and I have most enjoyed teaching and writing about programming languages and fiddling with new technologies!
I believe life is too short to ignore learning a programming language!

Comments and Discussions

Generalcomplete source code for a new messenger like yahoo messenger Pin
akhand858-Sep-09 21:11
Memberakhand858-Sep-09 21:11 
Generalfull source code for developing a new messenger Pin
Shah Nidhi K5-Aug-08 20:20
MemberShah Nidhi K5-Aug-08 20:20 
GeneralInstant Messenger Pin
chse72026-Apr-07 9:53
Memberchse72026-Apr-07 9:53 
GeneralRe: Instant Messenger Pin
vabsthegreat3-Aug-08 22:53
Membervabsthegreat3-Aug-08 22:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.