?
Solved

Some questions from VB newbie

Posted on 1999-01-22
5
Medium Priority
?
204 Views
Last Modified: 2010-05-18
1. How to make the TEXTBOX can only receive number?
   so, it will reject any alphabets.
2. I make the gradation color of my form from blue to
   black. The question is how to make the LABEL be
   transparent? So it will use the color of the form

Thank you for the attention.
Need the answer...

Stinger
0
Comment
Question by:stinger_60284
[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
5 Comments
 
LVL 1

Accepted Solution

by:
batdan earned 80 total points
ID: 1470076
1)  Double click on the textbox, then in the text1_change procedure insert the following code:

Text1_Change()

     If Not IsNumeric(Text1.Text) then
          Text1.Text = ""
     End If

End Sub


2)  Set the BackStyle property of the label to Transparent in the properties window.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 1470077
Question 1:

You have 2 choices: validate the keypress event of the TextBox or use a MaskEdit Control.

Here is the code for the KeyPress event:
Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
        KeyAscii = 0
    End If
End Sub

Question 2:
Change the Backstyle property of your label to Transparent.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1470078
Making a text box only accept numbers is not as easy as it might initially seem....

batdan's solution is OK but it fixes things after the fact: first the user types in rubbish, then you tell the user "you can't do that!"

Ideally you want to stop the user from typing in rubbish in the first place.

emoreau's solution is better in that it does this. But it isn't great either because now you can't paste into the text box anymore.

I'll dig up some code for handling this - just bear with me a moment....
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1470079
OK - look at this question:
http://www.experts-exchange.com/topics/bin/Q.10113932

This is a Previously Answered Question about "how to round euro" which has nothing to do with your question, but it is Free (no points) and it contains some example code.

In the example code there is a form with "numeric only" text boxes on it which has all the code you need.

Good luck!
0
 

Author Comment

by:stinger_60284
ID: 1470080
Thank you guys...
You are all cool experts!!!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month14 days, 16 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