Input box rounding

K

Karen53

Hi,

Could someone tell me why my value is rounding up to whole numbers, not
allowing decimals, i.e. 1.50 or 1.75 etc?

Sub EditAllowedVariance()

Dim HasPswd As String
Dim NuAllowance As Long

HasPswd = InputBox("Enter Password", "Password")

If HasPswd = "" Then
'do nothing
Else
If HasPswd = MyPassword Then
NuAllowance = Val(InputBox("Enter desired allowed variance",
"Enter Variance"))
GrossUppg.Range("I2").NumberFormat = "00.00"
GrossUppg.Range("I2").Value = NuAllowance
Else
MsgBox "Incorrect Password"
End If
End If

End Sub
 
R

Rick Rothstein \(MVP - VB\)

It is probably due to your Dim'ming NuAllowance as a Long... Long's cannot
hold decimal values. Try Dim'ming it as Double and see if that helps.

Rick
 
K

Karen53

Yes, Thank you, Rick!
--
Thanks for your help.
Karen53


Rick Rothstein (MVP - VB) said:
It is probably due to your Dim'ming NuAllowance as a Long... Long's cannot
hold decimal values. Try Dim'ming it as Double and see if that helps.

Rick
 
K

Karen53

Another question,

Is there a way I can set the password input box to mask the password with *?
--
Thanks for your help.
Karen53


Rick Rothstein (MVP - VB) said:
It is probably due to your Dim'ming NuAllowance as a Long... Long's cannot
hold decimal values. Try Dim'ming it as Double and see if that helps.

Rick
 
G

Gary Keramidas

yes, view the properties of the textbox and look for password character.

--


Gary Keramidas


Karen53 said:
Another question,

Is there a way I can set the password input box to mask the password with
*?
 

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