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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INPUTBOX only accept numeric characters

Status
Not open for further replies.

lpb71

Technical User
Mar 10, 2004
57
GB
How can I get my script below to only accept numeric input?

do
branchid = InputBox("Enter Branch Number (with leading 0s)")
if len(branchid)=3 and (branchid) then exit do
msgbox "Branch id needs to be 3 numbers with leading 0', please re-enter branchid"
loop

'Request Confirmation

ysno = MsgBox ("Please confirm details, branch=" & (branchid) & ", Select OK to Continue or Cancel tio Quit" ,vbOKCancel)
If ysno = 2 Then WScript.Quit
 
You will aslo want to move the input box to a function. That way you can check and see if it is numeric and if not it will just prompt again for the proper data.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
My script checks for that and uses the loop if not 3 digit
 
I have another problem now. I can't quit without typing data in. I added a line after if len(branchid)....etc
"if (branchid)<> then wscript.quit"
but got a syntax error.
 
A starting point:
If Trim(branchid & "") = "" Then
MsgBox "branchid is either null, empty, space or zero length"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have come across an issue with my script. The program that creates my file will create a second file with .1 extension once the first file reaches 2gb. How can I get my script to look if the .1 file exists before exiting and if it does exist, I want it to add the two file sizes together?

See script below.

'Set Explorer Objects
Set objExplorer = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
objExplorer.resizable =0

do While (objExplorer.Busy)
Loop

Set objDocument = objExplorer.Document
objDocument.Open
objDocument.WriteLn "<html><head><title>LREP Data Replication</title></head>"
objDocument.WriteLn "<body bgcolor='white'>"
objDocument.WriteLn "Replicating Data to USB Device. Please Wait....<p>"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("b" + (branchid) + "sr01.0")


FileSize1 = (objFile.Size)/1024
wscript.sleep 10000
FileSize2 = (objFile.Size)/1024


'Launch Progress screen

Do Until FileSize1 = FileSize2
wscript.sleep 3000
objDocument.WriteLn("File Size so far =" & (objFile.Size)/1024 & " kb <br>")
objDocument.Close
objDocument.Open
objDocument.WriteLn "<html><head><title>LREP Data Replication</title></head>"
objDocument.WriteLn "<body bgcolor='white'>"
objDocument.WriteLn "Replicating Data to USB Device. Please Wait....<p>"
FileSize1 = (objFile.Size)
objDocument.WriteLn("File Size so far =" & (objFile.Size)/1024 & " Kb <br>")
wscript.sleep 3000
FileSize2 = (objFile.Size)
objDocument.Close
Loop
objDocument.WriteLn "<br>Replication Complete."
objDocument.WriteLn"</body></html>"
wscript.sleep 4000
objDocument.Close
wscript.sleep 10000
objExplorer.Quit
MsgBox "Replication Complete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top