Jump to content

VB 6.0: Tutorial, Using the MsgBox

- - - - -

  • Please log in to reply
13 replies to this topic

#1
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Introduction:-

Ok, so here I will show you the basics of the MsgBox Function!

Requirements:-
    Visual Basic (preferibly 6.0)

Let's begin!

So the most basic method to display a Msgbox is:-

MsgBox "testing"

This will just show a msg box with an Ok Button!

But lets elaborate more on it:-

MsgBox "testing", vbOKOnly, "title"
This will display a msgbox with a title with an Ok Button

Posted Image

ok so thats the basic now lets elaborate more on out msgbox

msg = MsgBox("Testing", vbYesNoCancel)
If msg = vbYes Then Print "Yes Pressed"
If msg = vbNo Then Print "No Pressed"
If msg = vbCancel Then Print "Cancel Pressed"

and

msg = MsgBox("Testing", vbAbortRetryIgnore)
If msg = vbAbort Then Print "Abort Pressed"
If msg = vbRetry Then Print "Retry Pressed"
If msg = vbIgnore Then Print "Ignore Pressed"

Here a msg box with 3 buttons ( Yes, No, Cancel or Abort, Retry, Ignore) will be shown!
And if you see we added "msg = " here msg ( a variable )will hold in it what button the user pressed! then we are using the if...then so to make different actions, if different buttons are pressed!

Posted Image

ok now lets make an effect to our msgbox!!

msg = MsgBox("Testing", vbMsgBoxRtlReading + vbCritical)

This will display a msg box Inverted! ( the other way round )
After the "+" you can make every other type of msgbox you want and it will be inverted!!

Posted Image

And there are MUCH more MsgBoxes, I gave you the basics now you can elaborate on it!!

Ending:-
If you have any questions/problems/feedback pls post here and I will sureley Help you!
So I'm waiting for your feedback
Ow and if you want me to make you some tutorials request what you want and I will see what I can do! I will be happy making some tuts here!

#2
Guest_SlamX_*

Guest_SlamX_*
  • Guests
ty, was looking for this. +rep

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Thanks for the +rep :).

#4
Guest_nokomoli_*

Guest_nokomoli_*
  • Guests
Thank you

#5
Noxa

Noxa

    Newbie

  • Members
  • Pip
  • 1 posts
Thanks for this, ive just started using VB and its helped alot.

#6
ViRuSS

ViRuSS

    Learning Programmer

  • Members
  • PipPipPip
  • 78 posts
thx i just needed a little help with msgbox
:D

#7
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
For anyone using VB.NET, I would advise the MessageBox.Show() function over MsgBox() any day.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#8
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
  • Programming Language:Java, C#, PHP
  • Learning:C, C++, C#, PHP, Transact-SQL, Assembly, Scheme
Doesn't this tutorial apply to VB.NET also?

#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Yes, but the MsgBox() function is an old overhand of VB6, so in all cases MessageBox.Show() should be used instead in .NET. This applies to all .NET languages.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#10
AcroneShadow

AcroneShadow

    Newbie

  • Members
  • PipPip
  • 16 posts
very good, thanks for the post

#11
jamjum

jamjum

    Newbie

  • Members
  • Pip
  • 3 posts
thanks u helpe me alot with this tutrial

#12
Veron

Veron

    Newbie

  • Members
  • Pip
  • 1 posts
Hi,

Very informative, but I have question with respect to Msgbox() function.
How do I disable the movement of the Msgbox, because, as a user when right clicked on Title bar, will get the options (Move & Close), so how can I disable these options (Move & Close) which can disable the movement, please let me know, it is urgent.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users