Is there something wrong in this program?
Sub DetailProduct()
Dim code As String
Dim Length As Single
Dim Diameter As Single
Dim Colour As String
Dim ok As Boolean
ok = False
Do
code = InputBox("Please enter the 3 character product code.")
If code = "" Then
Exit Sub
End If
If IsNumeric(code) Then
ok = False
MsgBox "Error - you have entered the numeric input."
Else
If Len(code) <> 3 Then
ok = False
MsgBox "error- please enter 3 character product code."
Else
ok = True
Length = UCase(Left(code, 1, 1))
Diameter = UCase(Mid(code, 1, 2))
Colour = UCase(Right(code, 1))
Select Case Length
Case "A"
Length = 250
Case "B"
Length = 500
Case "C"
Length = 1000
Case "D"
Length = 3000
Case Else
MsgBox "error"
End Select
Select Case Diameter
Case "K"
Diameter = 30
Case "L"
Diameter = 45
Case "M"
Diameter = 60
Case "N"
Diameter = 100
Case Else
MsgBox "error"
End Select
Select Case Colour
Case "W"
Colour = "red"
Case "X"
Colour = "green"
Case "Y"
Colour = "blue"
Case "Z"
Colour = "white"
Case Else
MsgBox "error"
End Select
End If
End If
Loop Until code = "END"
MsgBox "The input " & code & " would produce the cylinder is " & Length & "mm by " & Diameter & "mm and is " & Colour
End Sub
Bookmarks