Solved

Some questions from VB newbie

Posted on 1999-01-22
5
198 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
5 Comments
 
LVL 1

Accepted Solution

by:
batdan earned 20 total points
Comment Utility
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 69

Expert Comment

by:Éric Moreau
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you guys...
You are all cool experts!!!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now