The following code only allows digits and a period (and only one period) with only one decimal after that period.
Be aware that this code only consider a period as a decimal sign so it's not localized for countries that use other signs (like commas in Scandinavia).
VB Code:
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2.     Dim nPos As Long
  3.    
  4.     Select Case KeyAscii
  5.         Case vbKeyBack
  6.             'We allow this so we do nothing
  7.         Case vbKey0 To vbKey9, Asc(".")
  8.             nPos = InStr(Text1, ".")
  9.             If nPos Then
  10.                 If Text1.SelStart > nPos Or KeyAscii = Asc(".") Then
  11.                     KeyAscii = 0
  12.                 ElseIf Text1.SelStart = nPos And Len(Text1.Text) > nPos Then
  13.                     KeyAscii = 0
  14.                 End If
  15.             End If
  16.         Case Else
  17.             'we dont allow any other characters
  18.             KeyAscii = 0
  19.     End Select
  20. End Sub
Best regards