Solved

Showing percentage of value in textbox

Posted on 2007-11-23
1
135 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

840 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