0

IsNumeric function returns different values according what user do. If user press OK with empty field , my code works as should. But when user press Cancel my code exits loop. Why? I need that InputBox dialog still appear infinitely until user enter number. How to do this?

    <package>
 <job id="NonDisabledServicesCollecting">
<COMMENT>
************************************************************
1 comment
2 
3 
************************************************************
</COMMENT>
  <script language="VBScript">
flash_folder="I:\123\"
str_flash_folder_colFiles = ""
num_flash_folder_colFiles = 0
Set flash_folder_colFiles = CreateObject("Scripting.FileSystemObject").GetFolder(flash_folder).Files
Dim table_flash_folder_colFiles()
ReDim Preserve table_flash_folder_colFiles(flash_folder_colFiles.Count) 'zero-element not used
For Each flash_folder_objFile in flash_folder_colFiles
  num_flash_folder_colFiles = num_flash_folder_colFiles + 1
  table_flash_folder_colFiles(num_flash_folder_colFiles) = flash_folder_objFile.Name
  str_flash_folder_colFiles = str_flash_folder_colFiles + cstr(num_flash_folder_colFiles) + " " + flash_folder_objFile.Name + vbCrLf
Next

Dim response
Do
  response = InputBox("Please enter the number that corresponds to your selection:" + vbCrLf + str_flash_folder_colFiles, "Choose DLL to copy...")
  If response = "" Then WScript.Echo "Input is empty." 'Detect Cancel
WScript.Echo response
WScript.Echo IsNumeric(response)
  If IsNumeric(response) Then Exit Do                  'Detect value response.
  WScript.Echo "You must enter a numeric value."
Loop
selected_flush_DLL= flash_folder + table_flash_folder_colFiles(cint(response))
WScript.Echo selected_flush_DLL

  </script>
 </job>
</package>

1 Answers1

0

I rewrite code next way and now it works as should:

    <package>
 <job id="NonDisabledServicesCollecting">
<COMMENT>
************************************************************
1 comment
2 
3 
************************************************************
</COMMENT>
  <script language="VBScript">
flash_folder="I:\123\"
str_flash_folder_colFiles = ""
num_flash_folder_colFiles = 0
Set flash_folder_colFiles = CreateObject("Scripting.FileSystemObject").GetFolder(flash_folder).Files
Dim table_flash_folder_colFiles()
ReDim Preserve table_flash_folder_colFiles(flash_folder_colFiles.Count) 'zero-element not used
For Each flash_folder_objFile in flash_folder_colFiles
  num_flash_folder_colFiles = num_flash_folder_colFiles + 1
  table_flash_folder_colFiles(num_flash_folder_colFiles) = flash_folder_objFile.Name
  str_flash_folder_colFiles = str_flash_folder_colFiles + cstr(num_flash_folder_colFiles) + " " + flash_folder_objFile.Name + vbCrLf
Next

Dim response
Do
  response = InputBox("Please enter the number that corresponds to your selection:" + vbCrLf + str_flash_folder_colFiles, "Choose DLL to copy...")
  If response = "" Then 
    WScript.Echo "Input is empty."       'Detect Cancel
  Else
    if IsNumeric(response) Then
      Exit Do  'Detect value response.
    else
      WScript.Echo "You must enter a numeric value."
    end if
  End If 
Loop
selected_flush_DLL= flash_folder + table_flash_folder_colFiles(cint(response))
WScript.Echo selected_flush_DLL

  </script>
 </job>
</package>