Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

VB MSG add on

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
4Merlin4
Asked:
4Merlin4
  • 3
  • 2
1 Solution
 
JacamarCommented:
Private sub Command1_Click
if txt.text ="" then
call msgbox ("Please fill the textbox", vbInformation)
end if
end sub
0
 
JacamarCommented:
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
 
4Merlin4Author Commented:
That way worked out perfectly to what I wanted to do.
0
 
4Merlin4Author Commented:
That worked out great...How would I go about making sure thier are only numbers there
0
 
JacamarCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now