?
Solved

VB MSG add on

Posted on 2003-02-18
5
Medium Priority
?
246 Views
Last Modified: 2010-05-01
How can I get a MSG box to show up when someone clicks on the Cmd Button and theres nothing in the assoicated txt box. The txt box is setup as Int = txt1.text
0
Comment
Question by:4Merlin4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Jacamar
ID: 7978742
Private sub Command1_Click
if txt.text ="" then
call msgbox ("Please fill the textbox", vbInformation)
end if
end sub
0
 
LVL 2

Accepted Solution

by:
Jacamar earned 200 total points
ID: 7978784
If txt.text is going to cause your program to crash if it is empty, I suggest to not enable the command button until the text box is filled with what you want.  This can be done in a

txt_change()
if txt.text = "" then
command.enabled = false
else command.enabled = true
end if
end sub

Also, make sure that you load the form with
 command.enabled = false

if you want help making sure that what is entered in to the textbox is what you want (ie. number range, only text, only numbers, ect), let me know.

Jacamar
0
 

Author Comment

by:4Merlin4
ID: 7979410
That way worked out perfectly to what I wanted to do.
0
 

Author Comment

by:4Merlin4
ID: 7979423
That worked out great...How would I go about making sure thier are only numbers there
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 7979459
The following code will make sure there is a number value in the textbox before it will enable the command

Private Sub Text1_Change()

If Not IsNumeric(Text1.Text) Then
    Command1.Enabled = False
End If

If IsNumeric(Text1.Text) Then
    Command1.Enabled = True
End If

If Text1.Text = "" Then
    Command1.Enabled = False
End If

end sub

Good luck.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question