kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
This part of the code is not giving me cute result.
My aim was to get a user input of integer values from one to five (maximum) numbers, which means it could be from 1 – 5 numbers. And these numbers must be integers, no floating numbers or decimals. Then the first number must always be 100. Then these numbers, if more than 1, must be in descending order. So I came up with this cool procedure, lol, meanwhile, my goals were not met. As I pointed out from the above, I am not getting the cutest outcome I needed. I need tech support with it.
Now, when I am able to get it working, my next goal was to store those numbers from the user input to a variable by multiplying each number in that array by 10.
That’s if I successfully entered “100,90,85,70”, which I convert to “100 90 85 70”, then my variable, MyVar should store “1000 900 850 700”. I am very grateful for your help. Thanks
Code:
If SysNum(i) < SysNum(i + 1) Then
MsgBox SysNum(i) & " " & SysNum(i + 1) & " The numbers must be in descending order!", vbExclamation
SysFlg = True
Else
SysFlg = False
End If
My aim was to get a user input of integer values from one to five (maximum) numbers, which means it could be from 1 – 5 numbers. And these numbers must be integers, no floating numbers or decimals. Then the first number must always be 100. Then these numbers, if more than 1, must be in descending order. So I came up with this cool procedure, lol, meanwhile, my goals were not met. As I pointed out from the above, I am not getting the cutest outcome I needed. I need tech support with it.
Now, when I am able to get it working, my next goal was to store those numbers from the user input to a variable by multiplying each number in that array by 10.
That’s if I successfully entered “100,90,85,70”, which I convert to “100 90 85 70”, then my variable, MyVar should store “1000 900 850 700”. I am very grateful for your help. Thanks
Code:
Sub MyProcedureNotWorking()
Dim SysNum , SysFlg As Boolean
SysFlg = True
While SysFlg = True
SysNum = InputBox("Enter the numbers,eg. 100,95,90 or 100 95 90 [Not more than 5 numbers”)
SysNum = Application.Trim(SysNum)
If SysNum = "" Then Exit Sub
SysNum = Replace(SysNum, ",", " ")
SysNum = Application.Trim(SysNum)
SysNum = Split(SysNum)
If UBound(SysNum) > 0 Then
For i = 0 To UBound(SysNum)
If Not IsNumeric(SysNum(i)) Then
MsgBox SysNum(i) & " is not a valid number, change it", vbExclamation
Else
Select Case i
Case 0 To UBound(SysNum) ' - 1
If SysNum(0) <> 100 Then
MsgBox "The first number must be 100!", vbExclamation
Else
SysFlg = False
End If
If SysNum(i) < SysNum(i + 1) Then
MsgBox SysNum(i) & " " & SysNum(i + 1) & " The numbers must be in descending order!", vbExclamation
SysFlg = True
Else
SysFlg = False
End If
End Select
End If
Next i
ElseIf UBound(SysNum) = 0 Then
If Not IsNumeric(SysNum(0)) Then
MsgBox SysNum(0) & " is not a valid number, change it", vbExclamation
Else
If SysNum(0) <> 100 Then
MsgBox "The first number must be 100!", vbExclamation
Else
SysFlg = False
End If
End If
End If
Wend
End Sub