Hey,
I am making a program where I am checking for invalid inputs from inputboxes.

I want to user to enter the amount of months for a loan into an inputbox. However, I am not being able to successfully check the problem. I tried the following but it did not work. I was hooping if someone could help me.

What I am doing is that I am check if the input is numbers or not... If it isn't a number then I ask the user to enter it again... However Once I get a number, I want to be able to check if it is a natural number or not. This is where I am having a problem. I am using the mod function, I am modding by 1 and checking if the remainder is 0, which it shouldn't be if the number is a decimal, however for some reason it is providing the number 0. Could someone help please.

VB Code:
  1. Do
  2.    
  3.         strMonths = InputBox("Please enter the number of months over which you wish the loan to be repaid. It must be a natural number", "Months")
  4.        
  5.         If StrPtr(strMonths) = 0 Then
  6.        
  7.             Exit Sub
  8.            
  9.         End If
  10.        
  11.         If strMonths = "" Or IsNumeric(strMonths) = False Then
  12.        
  13.             MsgBox "Please enter numbers only", , "Months Error - Numbers Only"
  14.            
  15.         End If
  16.            
  17.         If strMonths <> "" And IsNumeric(strMonths) = True Then
  18.                        
  19.             If lngMonths Mod 1 <> 0 Then
  20.        
  21.                 MsgBox "Please enter natural numbers only", vbCritical, "Months Error - Natural Numbers Only"
  22.        
  23.             End If
  24.            
  25.         End If
  26.        
  27.     Loop Until strMonths <> "" And IsNumeric(strMonths) = True And Val(strMonths) Mod 1 = 0