Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,549 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,847 people online right now. Registration is fast and FREE... Join Now!




"Display Message" button

2 Pages V  1 2 >  
Reply to this topicStart new topic

"Display Message" button, button for displaying input information

nvnorris
13 Aug, 2008 - 08:32 AM
Post #1

New D.I.C Head
*

Joined: 12 Mar, 2008
Posts: 2

I have not idea how to get started on this. I need to know how to display information that is entered into two text boxes using a "display message" button.
User is offlineProfile CardPM
+Quote Post

Locke37
RE: "Display Message" Button
13 Aug, 2008 - 09:24 AM
Post #2

I'm not a thief...I prefer the term TREASURE HUNTER!
Group Icon

Joined: 20 Mar, 2008
Posts: 1,031



Thanked: 41 times
Dream Kudos: 325
My Contributions
QUOTE(nvnorris @ 13 Aug, 2008 - 09:32 AM) *

I have not idea how to get started on this. I need to know how to display information that is entered into two text boxes using a "display message" button.


That's pretty easy, it's just accessing the textboxes text, which is also easy. biggrin.gif

vb
Private Sub Button1_Click()

Label1.Caption = TextBox1.Text & vbCrLf & TextBox2.Text

End Sub


You replace Button1, Label1, TextBox1, TextBox2 with your names for those things on your form.

Hope this helped! biggrin.gif
User is offlineProfile CardPM
+Quote Post

cmount
RE: "Display Message" Button
13 Aug, 2008 - 09:45 AM
Post #3

New D.I.C Head
*

Joined: 1 Aug, 2008
Posts: 41



Thanked: 1 times
My Contributions
QUOTE(Locke37 @ 13 Aug, 2008 - 10:24 AM) *

QUOTE(nvnorris @ 13 Aug, 2008 - 09:32 AM) *

I have not idea how to get started on this. I need to know how to display information that is entered into two text boxes using a "display message" button.


That's pretty easy, it's just accessing the textboxes text, which is also easy. biggrin.gif

vb
Private Sub Button1_Click()

Label1.Caption = TextBox1.Text & vbCrLf & TextBox2.Text

End Sub


You replace Button1, Label1, TextBox1, TextBox2 with your names for those things on your form.

Hope this helped! biggrin.gif


Am I understanding this correctly: the goal is to make clickable buttons based on the text input from textboxes?

Basically customizing what the button says based on the input text? That's rather cool...I might look at implementing that rather than my vbRetryCancel button (It would be nice to have custom text buttons rather than retry & cancel)!

Another random, dumb question on this note. How do you denote line breaks in message boxes, and can you do this for buttons w/ multiple-lines of text?
User is offlineProfile CardPM
+Quote Post

Locke37
RE: "Display Message" Button
13 Aug, 2008 - 12:54 PM
Post #4

I'm not a thief...I prefer the term TREASURE HUNTER!
Group Icon

Joined: 20 Mar, 2008
Posts: 1,031



Thanked: 41 times
Dream Kudos: 325
My Contributions
QUOTE(nvnorris @ 13 Aug, 2008 - 09:32 AM) *

Another random, dumb question on this note. How do you denote line breaks in message boxes, and can you do this for buttons w/ multiple-lines of text?


vbCrLf inserts a line break. The CrLf part of it stands for Carriage Return Line Feed, basically, pushing the <Enter> or <Return> key.

biggrin.gif

Example:

vb
MsgBox("This is" & vbCrLf & "my message!")


That will output this...(in a message box of course)

QUOTE
This is
my message!


This post has been edited by Locke37: 13 Aug, 2008 - 12:56 PM
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: "Display Message" Button
13 Aug, 2008 - 02:29 PM
Post #5

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
Also, vbNewLine can be used in place of vbCrLf to create new lines. It's a few more characters long but I think it's easier to remember, especially when you're new to this type of stuff.

This post has been edited by Zhalix: 13 Aug, 2008 - 02:30 PM
User is offlineProfile CardPM
+Quote Post

Locke37
RE: "Display Message" Button
13 Aug, 2008 - 03:07 PM
Post #6

I'm not a thief...I prefer the term TREASURE HUNTER!
Group Icon

Joined: 20 Mar, 2008
Posts: 1,031



Thanked: 41 times
Dream Kudos: 325
My Contributions
Ah, didn't know there was a vbNewLine. In my VB class, we always just used vbCrLf. biggrin.gif
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: "Display Message" Button
13 Aug, 2008 - 05:17 PM
Post #7

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
QUOTE(Locke37 @ 13 Aug, 2008 - 05:07 PM) *

Ah, didn't know there was a vbNewLine. In my VB class, we always just used vbCrLf. biggrin.gif


I didn't know about vbNewLine for a long time and I could never seem to remember the predefined constant vbCrLf for new lines, so every time I needed new lines I ended up using Google. Learning about vbNewLine was a blessing for me. Of course it was right after learning vbNewline that I memorized vbCrLf. Go figure. rolleyes.gif
User is offlineProfile CardPM
+Quote Post

thava
RE: "Display Message" Button
13 Aug, 2008 - 05:32 PM
Post #8

D.I.C Regular
Group Icon

Joined: 17 Apr, 2007
Posts: 450



Thanked: 18 times
Dream Kudos: 50
My Contributions
hi also use

chr(13)

for new line

User is offlineProfile CardPM
+Quote Post

cmount
RE: "Display Message" Button
14 Aug, 2008 - 05:05 AM
Post #9

New D.I.C Head
*

Joined: 1 Aug, 2008
Posts: 41



Thanked: 1 times
My Contributions
QUOTE(thava @ 13 Aug, 2008 - 06:32 PM) *

hi also use

chr(13)

for new line


Is there any quick, easy way to quickly change the text & actions for the buttons in a MsgBox, or would it be easier to just create a UserForm to accomplish this?

I'm just trying to wrap my head around a possible new way to do something. The other thing I was wondering is where you should place the code to tell a UserForm what actions to take when the buttons are clicked---I want the buttons to GoTo a certain marker in my main code, but that obviously is separate from the UserForm...so just trying to figure that out (if that makes any sense)

If you want to see my existing code, look for the thread I wrote with a lot of bumps & new questions & no replies from anyone else. It's called something like incorporating .exe command prompt file into VB
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: "Display Message" Button
14 Aug, 2008 - 07:28 AM
Post #10

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
You can change the buttons to some extent, by specifying one of the setups in the MsgBox function:

CODE
MsgBox "Hey", vbYesNoCancel, "Lalala"


However if you need more than that, you will want to make your own MessageBox. It's pretty simple so don't be afraid to go that route.

To check what the result was, there are a few ways to go about it. If there's only two possible buttons, OR if you only have two possible actions and therefore two of the three buttons do the same thing, then you can use this approach:

CODE
If MsgBox("Are you male?", vbYesNoCancel, "Question") = vbYes Then
    'Code
Else
    'Code
End If


However if you wanted it to act differently for each of the three buttons, you'd have to switch to another approach. Declare an integer variable to hold the result, and then call the function, like this:

CODE
Dim intResult As Integer

intResult = MsgBox("Are you male?", vbYesNoCancel, "Question")

If intResult = vbYes Then
    'Code
ElseIf intResult = vbNo Then
    'Code
ElseIf intResult = vbCancel Then
    'Code
End If


A list of most, if not all results from the MsgBox:
vbYes
vbNo
vbCancel
vbAbort
vbRetry
vbIgnore
vbOK
User is offlineProfile CardPM
+Quote Post

cmount
RE: "Display Message" Button
14 Aug, 2008 - 08:56 AM
Post #11

New D.I.C Head
*

Joined: 1 Aug, 2008
Posts: 41



Thanked: 1 times
My Contributions
QUOTE(Zhalix @ 14 Aug, 2008 - 08:28 AM) *

You can change the buttons to some extent, by specifying one of the setups in the MsgBox function:

CODE
MsgBox "Hey", vbYesNoCancel, "Lalala"


However if you need more than that, you will want to make your own MessageBox. It's pretty simple so don't be afraid to go that route.

To check what the result was, there are a few ways to go about it. If there's only two possible buttons, OR if you only have two possible actions and therefore two of the three buttons do the same thing, then you can use this approach:

CODE
If MsgBox("Are you male?", vbYesNoCancel, "Question") = vbYes Then
    'Code
Else
    'Code
End If


However if you wanted it to act differently for each of the three buttons, you'd have to switch to another approach. Declare an integer variable to hold the result, and then call the function, like this:

CODE
Dim intResult As Integer

intResult = MsgBox("Are you male?", vbYesNoCancel, "Question")

If intResult = vbYes Then
    'Code
ElseIf intResult = vbNo Then
    'Code
ElseIf intResult = vbCancel Then
    'Code
End If


A list of most, if not all results from the MsgBox:
vbYes
vbNo
vbCancel
vbAbort
vbRetry
vbIgnore
vbOK


I'm sorry I didn't specify exactly what I was trying to do. My message boxes currently already do this---I just am not entirely happy with the options of Yes No...forcing the user to read through my description when I'd really like the button to be more advanced & have a bit of a description in it...

Or have one button be something like "Start Over," and another be "Cancel" (note: my cancel button is a lot more complicated than just unloading the project/stopping the code. I have a routine it needs to run before it can actually stop (deleting the temp stuff it may have copied into the spreadsheet). For the full existing code, you can see my other post.

What I was thinking of doing was something like this userform (I really didn't want to go the userform route...but I want the custom buttons & to make it more visually friendly)

I attached a zip where I included the files that seemed to be generated when I used the File-->Export File thing in the microsoft VB thing when I had the form open. (one's a .frx, the other is a .frm)
This is just to give an idea what the thing's supposed to look like

I want the Yes: I want to cancel button on the userform to goto a certain line of code in my one module--the placeholder TempDelete

In my main module of my existing code (before I created the UserForm Cancelled_Prompt in an attempt to make the prompt a little more user friendly), I added:

CODE

Load Cancelled_Prompt     ' to load the userform
Cancelled_Prompt.Show    ' to make it visible



I wasn't sure what code I needed to add to either the userform or the main module to get the userform's buttons to do what I want within the code of my main module




Attached File(s)
Attached File  myform.zip ( 1.41k ) Number of downloads: 14
User is offlineProfile CardPM
+Quote Post

thava
RE: "Display Message" Button
14 Aug, 2008 - 05:34 PM
Post #12

D.I.C Regular
Group Icon

Joined: 17 Apr, 2007
Posts: 450



Thanked: 18 times
Dream Kudos: 50
My Contributions
hi buddy it is a too risky one if you want do this things then do it
you need not specify your seperate user form
add a normal form and name if frmmsg
now disable the min max button
now add a button array this is because you create a new button on runtime easily

now make a cls file clsmsg

now make a method showmessage
add parameters what ever you want think dont make all the things are needed
make it optional
now declare a variable like htis
dim Fmsg as new frmmsg
write the code here
fmsg.show (vbapp..modal)
write the code here

now when you clck the button the form must unload
unload me

now you can use this class fille anywhere in your project

hope you understand good luck icon_up.gif
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:04PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month