Solved

Showing percentage of value in textbox

Posted on 2007-11-23
1
132 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
ID: 20340159
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

863 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

24 Experts available now in Live!

Get 1:1 Help Now