|
-
Oct 14th, 2003, 09:40 PM
#1
Thread Starter
New Member
sub procedure message box help
Can someone help me in getting started with this I need to setup a sub procedure that when called will display a message box. the string variable needs to be a passed value between the calling procedure and the called procedure. I need several different messages box to be displayed some with just ok buttons and some with yes.no buttons. Any information I would greatly appreciate because i'm stuck on this.
thanks,
Michael Giberson
-
Oct 14th, 2003, 10:31 PM
#2
PowerPoster
A good start:
Code:
Public Sub DisplayMessageBox(ByVal strDisplay as String)
MessageBox.Show(strDisplay)
End Sub
-
Oct 14th, 2003, 10:40 PM
#3
Thread Starter
New Member
Thanks, how would i change what will be displayed in strmessage for each message box that i'm going to display, and what code would i write in to be able to change what buttons and icons will be displayed?
-
Oct 14th, 2003, 10:50 PM
#4
PowerPoster
I am not sure you are going down the right track with my code. Lets try again.
To show a messagebox, all you have to do is:
Code:
MessageBox.Show("My message here", "Title Here")
That will set the message and the title of the message box. You can do that anywhere you want in your code.
Now, you can add more to it by adding the button types you want and the icon you want displayed by adding more:
Code:
MessageBox.Show("My Message here.", "Title Here", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Changing the MessageBoxButtons.OK to other values will get you different buttons. The MessageBoxIcon.Exclamation is what is controling the icons. Changing those two values will allow you to customize the message box.
Microsoft help on the subject:
http://msdn.microsoft.com/library/de...classtopic.asp
-
Oct 15th, 2003, 01:19 AM
#5
Thread Starter
New Member
I appreciate your help very much but i'm not sure i'm communicating the right thing across so i put in an example of what i need it to do
start of example:
Private Sub mnuCalcItem_Click
DisplayMessagebox()
and I need the message box to display the text, title, ok button, and error icon.
Private Sub mnuSummary_Click
DisplayMessagebox()
I need the message box to display different text and title, and yes no buttons, and question icon.
Private Sub Displaymessagebox()
Messagebox.show()
end example
I'm not sure what to put into the messagebox.show inside of the Private Sub Displaymessagebox() so i can change what it says, what buttons are displayed, and icons displayed depending on which private sub called Displaymessagebox() and where do i state what exactly should be displayed, buttons show, and icons shown for each of the private subs?
Thank you for your help so far,
Michael Giberson
p.s. if you would like you can email me at [email protected]
-
Oct 15th, 2003, 01:53 AM
#6
I think what hellswraith is saying, and I agree with him, is that there is no point in having the MessageBox in another sub. The MessageBox method itself is only one line or one method so why move it to another sub? It just makes things harder than they need to be.
VB Code:
'start of example:
Private Sub mnuCalcItem_Click
MessageBox.Show("My Text Message Here", "Caption or Title Here", MessageBoxButtons.OK, MessageBoxIcon.Error)
'and I need the message box to display the text, title, ok button, and error icon.
Private Sub mnuSummary_Click
MessageBox.Show("My Text Message Here", "Caption or Title Here", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
'I need the message box to display different text and title, and yes no buttons, and question icon.
'end example
-
Oct 15th, 2003, 08:26 AM
#7
Thread Starter
New Member
Thanks to both of you guys for the help but unfortunately my project specifications say that i need to do this, and that's why I had to try and find some help on it because I couldn't figure it out.
-
Oct 15th, 2003, 11:01 AM
#8
PowerPoster
Those specifications are not very good then.
Anyway, you will basically create your Displaymessagebox() to accept all the arguments a messagebox accepts, then you pass those arguments down to the actual call to show the messagebox.
This is soooooooooo much bad design. It isn't accomplishing anything, and adds complication for NO reason. You need to talk to your boss, teacher, or whatever and ask why.
-
Oct 15th, 2003, 11:52 AM
#9
I think I can guess why.... the person who created the spcs subscribes to the "One sub, one action" theory..... and takes it to the ultimate degree..... bad juju...
TG
-
Oct 15th, 2003, 08:19 PM
#10
PowerPoster
Originally posted by techgnome
I think I can guess why.... the person who created the spcs subscribes to the "One sub, one action" theory..... and takes it to the ultimate degree..... bad juju...
TG
I can understand that, but all this person will be doing is creating a wrapper around a sub that already has one action.
The messagebox is a class, and Show is the method in that class. It is already overloaded and done. There is no reason to wrap it up in another sub....just doesn't makes sense.
Like you said, bad juju....
-
Jan 9th, 2007, 08:16 AM
#11
New Member
Re: sub procedure message box help
Well i have read through the above replies and indeed they helped alot too. So here is my query, iam displaying the messagebox on the ItemUpdating event of my gridview. The messagebox pops up with three buttons( yes,no,cancel) but clicking ok or cancel just gives me same results i.e when i click cancel, instead of canceling the updating operation, the gridview goes a head and updates even after clicking cancel.
Qn. How do make sure that clicking cancel stops updating the record.
-
Jan 9th, 2007, 08:41 AM
#12
Fanatic Member
Re: sub procedure message box help
This sounds to me like a school assignment. When you call the messagebox that is more than just an ok button, you should assign it to an integer then test that integer to see which button they pressed:
VB Code:
Dim i As Integer
i = MsgBox("Click Yes to do something, No to Deny or Cancel to Exit")
Select Case i
Case vbYes
'Do Something
Case vbNo
'Do Something
Case vbCancel
'Do Something
End Select
As for stopping the gridview from updating, it has a canceledit method that you can use and will discard all changes and cancel the update. I hope that helps some.
-
Jan 10th, 2007, 12:11 AM
#13
New Member
Re: sub procedure message box help
[QUOTE=dminder]This sounds to me like a school assignment. When you call the messagebox that is more than just an ok button, you should assign it to an integer then test that integer to see which button they pressed:
VB Code:
Dim i As Integer
i = MsgBox("Click Yes to do something, No to Deny or Cancel to Exit")
Select Case i
Case vbYes
'Do Something
Case vbNo
'Do Something
Case vbCancel
'Do Something
End Select
As for stopping the gridview from updating, it has a canceledit method that you can use and will discard all changes and cancel the update. I hope that helps some.[Yes this forum is a school and iam learning, real starter or is the forum closed for starters. ]
-
Jan 10th, 2007, 12:23 AM
#14
New Member
Re: sub procedure message box help
Yes this forum is a school, isn't it and iam learning, real starter or is the forum closed for starters.
-
Jan 10th, 2007, 07:55 AM
#15
Fanatic Member
Re: sub procedure message box help
No, the forum is not closed for learning, however most of us who post here do not like to do homework assignments for people. We would rather give them the ability and direction to learn the technologies themselves. There have been a few who have tried to snowball people on here into giving them the entire answer instead of putting in the time and effort most of us have to actually learn.
Anyways, I hope that bit of code I previously posted gets you to where you need. If you run into further problems or errors feel free to post them and we will be glad to be of assisstance.
D
-
Jan 11th, 2007, 12:34 AM
#16
New Member
Re: sub procedure message box help
Ok, hope to keep around then, otherwise i was about to step a side and give room for the Gurus .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|