Solved

Showing percentage of value in textbox

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

695 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