Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change user input text 3

Status
Not open for further replies.

Biocide

Programmer
Oct 12, 2005
12
SE
Hi
Im making a program that calculates different numbers.
These numbers is user inputs so the user can type in both e.x: 1,1 or 1.1 that will be calculated different.
How can i tell the program that 1.1 is the same as 1,1?

/Biocide
 
You could do a Replace() on the textbox(?) e.g. Replace all occuraces of a "." with a "," into the string.
Code:
Dim strCalc as String
strCalc = Replace(text1.text,".",",")
...your code to calculate using strCalc
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Perhaps something like this:
myVar = Replace(myVar, ",", ".")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I did it like this:
M0F1 = Replace(M0F1, ".", ",")
M1F1 = Replace(M1F1, ".", ",")
M2F1 = Replace(M2F1, ".", ",")

But do i have to doit once for every textbox?
 
Create a function to do it and then pass the textbox name as an argument

Code:
Function Standardise(ByVal [b]WhatToStandardise[/b] As String) As String

Standardise = Replace(WhatToStandardise, ",", ".")

End Function

Sub Standardise_All()
For Each ctrl In UserForm1.Controls
   If uCase(TypeName(ctrl)) = "TEXTBOX" Then
      ctrl.Value = CDbl([b]Standardise(ctrl.Text)[/b])
   End If
Next
End Sub

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
How many textboxes do you have?

If it is 3 then it probably is easiest to do it like that.

If there is a higher number of textboxes then you could try concatenating the entries (with a delimiter e.g. |), doing a replace on the formed string and then splitting the result.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
That's much easier to use than my suggestion... [smile]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top