pLeAsE hELp! format function in excel visual basic editor

A

Alpineman2

How do I format a textbox ([Input Textbox] & [Sum (locked) Textbox]) within a
Userform in the following formats:
Numeric - such as ###,###,###.## (using 1000 separator [,])
Currency
Accounting
Percentage
Date

Note: I am a newbie, if someone would explain the function and where I would
implement such. I would greatly appreciate any guidance.
 
J

Joel

You need to convert the number to a string using the format function. the
format parameter is the same as the worksheet formats that you can look at in
the menu
Format - Cells - Number. for example

mystring = format(mynumber,"general")
mystring = format(mynumber,"#0")
mystring = format(mydate,"mm-yyyyl")
mystring = format(mynumber,"###,###,###.##l")
 
A

Alpineman2

Hi Joel,

Thank you, but I don't quite understand one thing. Where I place "mystring
= format" code?
Below is an example of what I am trying to accomplish:
Private Sub CommandButton1_Click()
TextBox4.Text = (TextBox1.Text / 43560)
End Sub

I do very much appreciate your help.
Thank you,

J.Brice

Joel said:
You need to convert the number to a string using the format function. the
format parameter is the same as the worksheet formats that you can look at in
the menu
Format - Cells - Number. for example

mystring = format(mynumber,"general")
mystring = format(mynumber,"#0")
mystring = format(mydate,"mm-yyyyl")
mystring = format(mynumber,"###,###,###.##l")


Alpineman2 said:
How do I format a textbox ([Input Textbox] & [Sum (locked) Textbox]) within a
Userform in the following formats:
Numeric - such as ###,###,###.## (using 1000 separator [,])
Currency
Accounting
Percentage
Date

Note: I am a newbie, if someone would explain the function and where I would
implement such. I would greatly appreciate any guidance.
 
J

Joel

It looks like your have to go from text to numberic back to text. I'm going
to use an intemediate variable, but it is not necessary

Private Sub CommandButton1_Click()
numbervalue = val(TextBox1.Text) / 43560# 'convert to number
TextBox4.Text = format(numbervalue,"###,###,###.##")
End Sub


Alpineman2 said:
Hi Joel,

Thank you, but I don't quite understand one thing. Where I place "mystring
= format" code?
Below is an example of what I am trying to accomplish:
Private Sub CommandButton1_Click()
TextBox4.Text = (TextBox1.Text / 43560)
End Sub

I do very much appreciate your help.
Thank you,

J.Brice

Joel said:
You need to convert the number to a string using the format function. the
format parameter is the same as the worksheet formats that you can look at in
the menu
Format - Cells - Number. for example

mystring = format(mynumber,"general")
mystring = format(mynumber,"#0")
mystring = format(mydate,"mm-yyyyl")
mystring = format(mynumber,"###,###,###.##l")


Alpineman2 said:
How do I format a textbox ([Input Textbox] & [Sum (locked) Textbox]) within a
Userform in the following formats:
Numeric - such as ###,###,###.## (using 1000 separator [,])
Currency
Accounting
Percentage
Date

Note: I am a newbie, if someone would explain the function and where I would
implement such. I would greatly appreciate any guidance.
 
A

Alpineman2

Joel,

It worked!! Thank you very much.

J.Brice

Joel said:
It looks like your have to go from text to numberic back to text. I'm going
to use an intemediate variable, but it is not necessary

Private Sub CommandButton1_Click()
numbervalue = val(TextBox1.Text) / 43560# 'convert to number
TextBox4.Text = format(numbervalue,"###,###,###.##")
End Sub


Alpineman2 said:
Hi Joel,

Thank you, but I don't quite understand one thing. Where I place "mystring
= format" code?
Below is an example of what I am trying to accomplish:
Private Sub CommandButton1_Click()
TextBox4.Text = (TextBox1.Text / 43560)
End Sub

I do very much appreciate your help.
Thank you,

J.Brice

Joel said:
You need to convert the number to a string using the format function. the
format parameter is the same as the worksheet formats that you can look at in
the menu
Format - Cells - Number. for example

mystring = format(mynumber,"general")
mystring = format(mynumber,"#0")
mystring = format(mydate,"mm-yyyyl")
mystring = format(mynumber,"###,###,###.##l")


:

How do I format a textbox ([Input Textbox] & [Sum (locked) Textbox]) within a
Userform in the following formats:
Numeric - such as ###,###,###.## (using 1000 separator [,])
Currency
Accounting
Percentage
Date

Note: I am a newbie, if someone would explain the function and where I would
implement such. I would greatly appreciate any guidance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top