Solved

Some questions from VB newbie

Posted on 1999-01-22
5
202 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 20 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 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