Solved

Showing percentage of value in textbox

Posted on 2007-11-23
1
131 Views
Last Modified: 2013-12-25
Hi
Does anyone know how I can return a % in a textbox based on a txtbox which changes from txtboxs which accepts numbers

Many Thanks
Andy
0
Comment
Question by:samandrew
1 Comment
 
LVL 38

Accepted Solution

by:
PaulHews earned 250 total points
Comment Utility
Assuming Text1 to receive Text2/Text3:
Option Explicit
 

Private Sub Command1_Click()

    If IsNumeric(Text2.Text) And IsNumeric(Text3.Text) Then

        If CDbl(Text3.Text) < 0.00001 Then

            ''Avoid divide by zero

            Text1.Text = "0"

        Else

            Text1.Text = Format(CDbl(Text2.Text) / CDbl(Text3.Text), "Percent")

        End If

    End If

End Sub

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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 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…

771 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

12 Experts available now in Live!

Get 1:1 Help Now