validating user input when using vba
Posted on 2007-08-09
Below is the code I'm using in powerpoint but I'm trying to self teach myself vba and I'm a little stuck here. This code runs just fine but what I want to do is validate the 6 digit id number and the user name. I don't want the message box to export the data to my csv file if he enters more or less than 6 digits or if he enters text. I want it to simply pop up over and over again until he enters exactly 6 digits. Same thing with the message box asking for his first name. If he enters numbers instead of text I don't want it to record the data unless he enters text. I want that one to also pop up over and over until he enters text. I know it can be done but I'm clueless as to how. thx!!
Public Sub Driverid()
' after driver inputs his id# it will export it to a csv file
Dim strID As String ' this can be local if you don't use it anwher else!
strID = InputBox(prompt:="Please enter your 6 digit driver ID#", _
Title:="Welcome to Excellence through Education!")
Open "C:\Documents and Settings\mikee\Desktop\testfile.csv" For Append As #1
Print #1, strID
mUserName = InputBox(prompt:="Type your FIRST name only", Title:="Personalize")