Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Currency Input To Textbox


Please let me illustrate what I'm trying to do:

On the form, I have 10 command buttons, Numbered 0 through 9. I also have 1 text box formatted for currency.

Each command button would have some code like this:
txtCurrency.text = txtCurrency.text & "1" ' replace "1" with whatever command button it is.


What I want to happen is the text box to automatically place a currency decimal point as the user enters numbers.

Example:
User enters 1, textbox looks like ".01"
User then enters 0, text box looks like ".10"
User then enters 5, text box looks like "1.05"
User then enters 0, text box looks like "10.50"

Anyone have any ideas?

Nick




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
TextBox Wanting To Make Input Text In Currency Format
Ok I am wanting to make the text typed into the textbox to be in currency format.

What I am wanting specifcally is when the user inputs text like; 30,000 or 30000 to automatically change it to $30,000.00

So if they were to type 1 it would be $1.00 or 100 $100.00 ect ect ect

Can this be done?

Currency Input
Im making a textbox where the user has to input a monetary value for e.g. "$10,000.00" ... any one have any efficient code that converts numerical values into currency formats?

For e.g. "10000" -> to be converted/validated into "$10,000.00"

User Currency Input
I am trying to find the best way to force a user to enter a currency amount. I have tried using the maskedit box but I find it unfriendly. For instance when you press the period it doesn't automatically go to the decimal portion of the currency amount.
Is there a better way?

Using Maskedit For Currency Input
I have a maskedit with mask: #,###,###.##

at runtime, it appears like this: _,___,___.__

that's fine... but i need the program to format the maskedit on lost focus making the other blanks 0,000,000.00 if not filled in


supposing i just typed in 1 so it would look like this: 1,___,___.__

on lostfocus i need it to be formatted like this 1,000,000.00

but format(maskedit1,"#,###,###.00" doesn't work.. need help stat.

Currency In Textbox
Hey all, im in need of some help in checking for decimal place and other stuff in my txt box.

this is my code right now:

Code:
Private Sub cmdCashTotal_Click()
Dim Change As Currency
Dim LooseChange As Currency

If txtDigits = "$" Or txtDigits = "" Then
MsgBox "Your need to enter an amount first", vbInformation
ElseIf Mid(txtDigits, 3, 1) <> "." Or Right(txtDigits.Text, 1) = "." Then
MsgBox "you need to enter a correct amount", vbInformation
Else
If cmdCashTotal.Tag = "GotChange" Then
Change = Format(Replace(Val(txtDigits.Text - txtHoldChange), "$", ""), "0.00")
GoTo B
Else
cmdCashTotal.Tag = "NoChange"
Change = Format(Replace(Val(txtDigits.Text - lblTaxTotal), "$", ""), "0.00")
End If
B:
If Change < 0 Then
MsgBox "You need " & Replace(Change, "-", "") & " more to complete this transaction", vbCritical
LooseChange = Format(Replace(Change, "-", ""), "0.00")
txtHoldChange = LooseChange
cmdCashTotal.Tag = "GotChange"
txtDigits.ForeColor = &HFF&
txtDigits.Text = "$" & txtHoldChange
Else
txtDigits.Text = "$"
lblChange = "$" & Change
End If
End If
End Sub

Problem with the code above is that if i enter $100 then it will tell me that "you need to enter a correct amount".

It works fine if i have an amount like $20 or even $20. or 20.0

But once i try putting $20.00 for some reason it still tells me "you need to enter a correct amount".

It works fine with $1.00-9.00.

All i am wanting is to check if the user enters a correct currency in the text box (IE: $15.00) not 15 or 15.0.. somewhere along those lines.

Any help would be great, thanks.

David

Textbox Currency
Ok I know the format for currency but what I want to occur on my textbox is not happening.

I have a textbox so the user can enter the total salary....so I typed in the format I learned and use for all other labels and such: txtName.Text=Format(txtName.Text,"currency")

But when the user enters a multiple digit (say 25) it shows it this way:
2$5.00. How come? Which would be the correct type for this? Are the label and textboxes formatting different?

Currency Textbox
I currently have a text box where I enter a $ amount. It has a mask of #########.##. Currently I have to count spaces when it comes to putting in the correct amount. What can I do to make this text box function in the following way. If i put in 12548.34 it will automatically pop in, and if I enter 12548, it will automatically pop in 12548.00.

Any Help is greatly appreciated.

Best Way, Textbox With Currency
Hello Everyone...

I must be making this more difficult than it really is... What is the simplest (maybe not the best) way to force a textbox to only accept numbers, the "." (decimal point, but not the $), and to always display 2 decimal places.

Displaying Currency In A Textbox
I have data (a cost) in a text box (ex. $35.33). I want to take this cost and display it in a messagebox. However, no matter how I seem to format it, I get the following: 35.55. I can always append a $, but what about when I get $35.33 in the textbox and there are extra digits? They are rounded in the textbox, but in the message box it is display like 35.333 OR if it's $46.00 in the textbox, the message box gets just 46.




HELP PLEEEESE.

Edit: Moved from Database

Formatting A Textbox As Currency
Hi there,
I have a normal ADO recordset with a Price field (currency), but i can't seem to get it formattet as the local currency in a textbox.
How do i do such thing?
Thanks in advance, Peter

Displaying Currency In Textbox
I have a requirement where I need to show a field in currency format (comma separated) when i tabout of a text field.
eg:TextBox contains 9123456.678
I need to display textbox value as 9,123,456.678 on tabout
Is there any inbuilt function which does this conversion or can someone provide pointers as to how to write function for this??

Formatting A Textbox For Currency
I am taking data from a database and loading it into a form. The form and the database are connect using a Data Controller. I need one of the textboxes that is displaying the data to show the data as currancy. I know how to make a textbox display a variable as currancy, but I can't get any variation of this to work.

Thanks,
bsac4
New to VB

How Format A Textbox For Currency
How to format a textbox for currency without using Maskedit Box. The only way at the moment is read the textbox and write back to the textbox with format function in the coding. This somehow creates some complication in the multiuser environment because the data is bound to a table.
Because it writes back to the textbox with the currency format "#,###,##0.00" it's actually changing the field.

Is it possible using API? Or is there any possible way where the format can be set and without have to use Maskedit or Richtextbox.

Please advise..

Thanking in advance

TextBox Formating - Currency
I have textboxes in which I would like to force the user input to look like currency after the textbox looses
focus.

I placed the following text in validation...

text1.text=formatcurrency(text1.text,2) but end up with a stack overflow error.



  

Currency Format In Bound Textbox
Can someone help me out, I'm new to VB? I'm trying to currency format a db bound textbox. When I use "txtFields(3) = Format(txtFields(3).text, "Currency")" on a change event, I can't modify my data properly because it's triggered on the first keystroke.
I'm running vb5 and can't find any help on MS.

Thanks Thinker, the lostfocus event is good but formating does not appear on the form_load event. How can I trigger it to load with formats?

Showing A Currency(1500.00) Value In Textbox
How to Show a currency(1500.00) value in textbox
If the value is 1500 then i need to show it as 1500.00

Currency Problem With TextBox &lt;Resolved&gt;
Hi,

I have a Text Box that will display/get the value in € of a said product. When I insert the value "100" it shows exactly that "100" but I would like it to show "100,00" without having to type in the comma and the zeros.

Can anyone help me with this?




Thanks in Advance,
Zmei



Edited by - Zmei2004 on 7/9/2004 6:59:50 AM

Make A Textbox Only Accept Currency Type?
how do i make it so the user can only enter a currency type into a textbox, meaning the user can only insert a period and numbers.

Insert Currency Data Type To MS Access Currency Field
Im want to insert a into a currency field in ms access using vb 6.0 but i keep gettin an error message. What should i place around the value to denote insert it.
here is my code:



VB Code:
Dim sqlstmt As String            sqlstmt = "INSERT INTO tbl_Products (ProductName,ProductDesc,SalesPrice,SpecialOffer,SpecialOfferPrice) VALUES (" & _              "'" & p_prodName & "', " & _              "'" & p_prodDesc & "', " & _              "'" & p_sPrice & "', " & _              "'" & p_specialOffer & "', " & _              "'" & p_soPrice & "' " & _              ")" MsgBox sqlstmt    db.Execute (sqlstmt)

Numeric Currency Value To Word Currency Value
Hi,
Guys I want to know how we can change Numeric Value of currency to the Word value.
Means,
for Ex. If we enter value in textbox “210” after clicking a button change, it will display in the label that “Two Hundred ten only” in label.
I want at least for up to 5 digit.

So I want this type of program for VB Give me whole coding for that Or attach the whole created project that u have done plz help me.

By the way, Happy DIWALI & new YEAR , It is Indian Festival.

Format Currency To Indian Format In Label/Textbox
Hi folks,
I am trying format the currency data in DB (Acs 2003) into Indian currency format 00,00,00,000 for which I used the below code

vbcode Code:
Me.lblAmt.Caption = Format(CCur(rsCurrent.Fields("suitAmount")), "##,##,##,##,##,##0")

but during display nothing happens i.e. the display continues to be the US format.
Can somebody show me how.
Thanks in advance.

Textbox Input
how do i make sure the user can only type numbers into a textbox and not letter???

Help With Textbox Input In VB 6
basically the attached file says it all. I want to know how to take input from a text box of one form and use it on a different form. Thanks for any help.

P.S. this is my 1st post ozzyosb1@tampabay.rr.com

Input Into Textbox HELP!!!
I need to know how to make an automated program that inserts text into a textbox which is in another program e.g. a login screen that i want automated to insert my username and password (just an example). Please Help....

Textbox Input
How can I set a text box to only take numbers?

TextBox Input
Hi all,

I have a standard text box to which I require someone to enter a phone number in the following format:
020 7123 1234

is there any way that I can only allow users to enter a number in this format?

I do not want users to deviate from the format before and therefore need to validate it.

Any help/advice would be great.

Regards,

Rocks

TextBox Input
As a pre-newbie to visual basic, I haven't programmed for years and I
am having the greatest of difficulties coping with it. If any kind
soul can help me out with advice then I'd be most grateful.

I am at the stage where I can design a form where I can insert text
boxes. You type in a word in textbox1, press OK and it appears in
textbox2. Not rocket science I know. But I trust this gives you a
feel for my level.

What I want to do is this:

As you type a character into textbox1 then this character is instantly
displayed in textbox2 and, this for me is the tricky bit, YOU DON'T
NEED TO PRESS RETURN or OK or any button at all. Please excuse the
shouting.

(What I will be designing eventually will be a translation program
which converts Roman numerals into Arabic numerals. Each letter as
entered in textbox1 will be translated into Arabic numerals, after
validation, and displayed in textbox2. I've written the validation
algorithm, have desk-checked it and it works.)

Before anyone feels tempted to flame or to scorn, I have RTFM, in fact
various FM's and nothing seems to help here. InputBoxes won't do, of
course.

In ye old BASIC it might go something like this

INPUT "Type in a letter"; letter$
GOSUB loads of validation and processing
PRINT letter$

This probably looks like Elvish to anyone born after 1980.

Thanks if you can help.

Bob

Input Within A Textbox In VBA
Hello,
I'm busy with VBA in excel.
Does anybody know how to control the input within a textbox? For example, a
textbox must contain only numbers and no text. The program must give a
warning if you type text in the textbox.

Greetings,
Hans

Textbox Input Not Working
I have a textbox on a worksheet, when I make a button on the sheet and assign exhdcp.text = date it puts the dat in the textbox. When I do this form another sheet I get an error.
I am sure that I should be setting something just dont know what.
VBA:
(doing this from a sheet called Leden)

Private Sub CommandButton1_Click()
Worksheets("Hdcp Heren").Activate
datehdcp.Text = Date
End Sub
Any help

Input From Textbox Put Into Listbox
how will i split the statement in the textbox and put each word in the listbox?
NOTE: no variable to be used

sample: visual basic program
output: visual
basic
program

How To Input Characters From Textbox??
Hello...

I want to temporary store a different number of uppercase letters that will be pasted in a textbox. After that i want to use the index of coincidece to that characters.

What do you suggest?

Thanks

How To Control Input In Textbox
hi,
i want to know that,if i press ENTER KEY in textbox then how can i check it ?
because i want to perform some task when user presses the ENTER KEY.
looking forward for ur replies.
thanks in advance !

Textbox (input Password)
I have a textbox in a form for input a password to open my application.
Is there some "nice" and "easy" way to make this code.
I want that the character/figures don't be shown, only replaced with "*" for
each character that been inputed.

Problem With Textbox (input)
Hi,
I am having a problem with textbox.
the problem is that i want in that text box only number get in: that was easy by using keypress event like shown below


Code:
Private Sub txtlength_KeyPress(KeyAscii As Integer)
Const vbKeyDecPt = 46
If KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Or _
KeyAscii = vbKeyBack Or KeyAscii = vbKeyDecPt Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub

but in the text box, the decimal point can be input more than once like (2.55.1.2) which is not good.

Ideas are appreciated (with code) to solve my problem

I don't know how to apply format to input

Getting Characters From Textbox Input...
I was wondering how I get a certain character out of a textbox. For instance, if I press < i want a box to popup. or if i press <font i would want a box to popup.. How would i get this? A example code would be of some great help.. Thanks

Cannot Input Text In The Textbox
I cannot insert any input into my textbox. Every time I insert one text or number from keyboard, I got this messagebox MsgBox "Please input valid password", vbCritical, "Warning". So How I can input full password into my textbox?


Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii ' This case statment check that no text can be entered.
Case vbKeyDelete ' Delete Key
Case vbKeyBack 'Baskspace key
Case vbKeyReturn
Case Else
Dim usrnm As String
usrnm = TextBox1.Text
adoRS.Close
adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic
If adoRS.Fields("Password").Value = TextBox1.Text And adoRS.Fields("username").Value = "Pengurus" Then
pass = True
'if password valid, success
Unload Me
frmMain.Show
Else

'If password invalid
intCounter = intCounter + 1
If intCounter = 4 Then
MsgBox "You have insert invalid password more then 3", vbCritical, "Warning"
intCounter = 0
Unload Me
Application.Shutdown
Else
MsgBox "Please input valid password", vbCritical, "Warning"
TextBox1.SetFocus
TextBox1.Text = ""
End If
End If

Input Number In The Textbox
I want allow the decimal number or interger can be input in the textbox.No String data are allowed to be input in the textbox. I try to avoid the error input by the user using
Code:
,
and
Code:
.
. I used desktop computer to input the value from Keyboard. Is there a difference code between input the value from keyboard for desktop computer and notebook?

Input Mask For Textbox
hi i did search but i didnt find quite what i was looking for. from reading the forums i have found out that there is no input mask control that comes with the textbox but there may be something in the components?
I have a textbox used for the post/zip code and i need an input mask but i dont know how to get an input mask. if anyone has any suggestions or code that could help please could you explain it to me as well so i get an understanding of what is happening. Thanks in advance

How To Use Textbox Value In A Function As A Input Value?
Am using sql server 2005.. i wanna use custom code there using vb..
i wanna use one textbox value as an input and have to get output in another textbox...so how can i use tat textbox1 value in function and refer it? please help me friends

Textbox (integer Input Only)
i have a textbox and the user are not allowed to input other data type unless it is integer

Textbox Check For Input And Value
hi everyone,

i have a small problem.
i was trying to make a programm that checks for input or no input and if there is input then check the boundaries(between -50 and 50).
if one of them is incorrect then show a message.
here is the code:

VB Code:
Private Sub Command1_Click()

Private Sub Command1_Click()
For z = 0 To 3
If Text1(z) = "" Then
MsgBox "U heeft het " & z + 1 & "e tekstvak niet ingevuld!!", vbExclamation, "Waarschuwing!"
Else
bereik
End If
Next z

End Sub

Private Sub bereik()

g(0) = Val(Text1(0))
g(1) = Val(Text1(1))
g(2) = Val(Text1(2))
g(3) = Val(Text1(3))

For x = 0 To 3
If g(x) < -50 Or g(x) > 50 Then
MsgBox "foute getal"
End If
Next x
End Sub

VB Code:
end of code

now it shows me 4 times the message which is logical,but i only want the messagebox once
can someone tell me how to solve the problem.
this might be an easy question for others but right now i don't see it.
many thanks in advance.
greetings,
pascal

Check Textbox Input
Could someone point me in the right direction as to how i would go about checking a textbox for a date input format as DD/MM/YYYY thanks in advance RedAngel

HAPPY NEW YEAR TO ALL............

Progress Bar With Input Box (TextBox)
Hi

I have a simple IM program but I would like to show the user when the limit of text to be sent is reached!

Basically, I need it to count how many letters the user has typed, and show it up in a 'Progress Bar'
ie.
0 characters - 0 bars
250 characters - 5 bars
500 characters - 10 bars


If anyone could help that would be great

Checking For An Input In A Textbox
Hello

How can i check if there is an input in a textbox?

i mean i have got a textbox which has some value 6,

at times it might not have a value(it is empty), how can i check for such a condition?

Need Help Validating Textbox Input
I'm doing a GUI for a spreadsheet of mine and its the first time i'm using VB so im in need of a few shortcuts/tricks.

I have 40+ textboxes in the GUI (and could be adding a fair few more) most of them require positive number input, though some require only positive integers and a couple can have negative values.
I want the numbers to update in "real-time" so I can't only use AfterUpdate but i have to deal with invalid inputs (non-numbers) and circumstances like decimal points and negative signs.
I have eventually got some code that works (see below) but it requires code in Textbox_change, Textbox_afterupdate and Textbox_Keypress and I would rather have a function that only needs to appear in one (or two) of these.


VB Code:
Dim oldVal As String Function store(astring As String)oldVal = astringEnd Function Function checkNum(astring As String, Optional negAllowed As Integer, optional intOnly as integer) As StringDim i As IntegerDim isValid As BooleanDim decimalExists As BooleandecimalExists = FalseisValid = True i = 1For i = 1 To Len(astring)    char = Mid(astring, i, 1)            If (Asc(char) < 48 Or Asc(char) > 57) Then ' 48-57 -> numbers 0-9        If Asc(char) = 45 Then ' 45 = minus sign            If i <> 1 Or negAllowed <> 1 Then            isValid = False            End If        ElseIf Asc(char) = 46 Then '46 = decimal point            If decimalExists = False and intOnly <> 1 Then            decimalExists = True            Else            isValid = False            End If        Else        isValid = False        End If    End If         Next i If isValid = False ThencheckNum = oldValElsecheckNum = astringEnd IfEnd Function Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)store (TextBox1.value)End Sub Private Sub TextBox1_Change()TextBox1.value = checkNum(TextBox1.value)If TextBox1.value <> "" And TextBox1.value <> "-" Or Right(TextBox1.value, 1) <> "." Then'do whatever function needs to be done hereEnd IfEnd Sub Private Sub TextBox1_AfterUpdate()If TextBox1.value = "" Or TextBox1.value = "-" Or TextBox1.value = "." ThenTextBox1.value = 0 'or whatever the default value isEnd IfTextBox1.value = TextBox1.value * 1 'gets rid of leading zero and lagging decimal pointEnd Sub


so if someone has some "cleaner" or more concise code i could use it would be much appreciated.

Preventing Input Into A TextBox
How can you prevent any input into a textbox beside setting setting the .enabled = false?

Input Lines From Textbox.
How are you I have this small experiment thing happening and i have a text file with five lines of just things. I can open the text file and do what i want but i can't figure out how to read lines and let thm be the Array and things like that i 'll show you what i have.


Private Sub Command1_Click()

Static line

Open inputfile.txt For Input As #1

For I = 1 To 5
Line Input #1, line(I)
Next I

lable1.Caption = line(1)

End Sub

This is just very simplified how do i do it so i can just have it inputing from a text box say for example text1 or something and then do exacly the same thing.

Gooday

MSComm Input In Textbox
HI!

If you want to sent for example the text "hello world" to the serial port you write : MSComm1.Output = "Hellow world".

But i dont know how can i sent the serial port input to a text box.

Can anyone help me please?
Thanks

Help Comparing A Textbox Input
I am trying to make a simple program wich ask your name, and if the name entered is "edna" it should display a msgbox with a statement. If not it should display a different statement. IThe problem is that i do not know how to tell VB to search for the character. If I use it with numbers the program runs ok, but with letters it just do the "else" option. The code I am using (with numbers) is bellow.

Private Sub Command1_Click()
If Text1 = 1 Then ' verifica si el nombre es 1
MsgBox "Hola Mi Grillitico" 'visualiza mensaje para 1
Else ' si no es edna
MsgBox "hola " + Text1
End If
End Sub

Copyright © 2005-08 www.BigResource.com, All rights reserved