SOLVED

Query related to VBA code

Iron Contributor

Hello Everyone, 

 

I am trying to work with input variable and using msgbox- if the information is correct-> then there should be no "Please re-enter your PURCHASED ORDER number"

 

Please help..

 

Here is a attached file.. 

 

6 Replies
best response confirmed by Excel (Iron Contributor)
Solution

@Excel 

 

Give a try on below sub

Public Sub Information()
ReEnter:
    ' Create inputbox, and (2) asssign value returned by inputbox function to variable
    myInputBoxVariable = InputBox(prompt:="Please enter your PO number", Title:="PO Number")
    
        ' Display message box with value held by varaible
        If IsNumeric(myInputBoxVariable) Then
            MsgBox " Your PO number is:  " & myInputBoxVariable
        Else
            GoTo Incorrect
        End If
    
    ' If error, check with the PO value again
    On Error GoTo Incorrect
    
    Exit Sub
Incorrect:     MsgBox "Please re-enter your PO number"
    GoTo ReEnter
End Sub
Thank you so much sir

@Harun24HR 

 

 

 

Hello Sir, 

I have a very small question that :

In below screnshot, When i have checked the EVALUATE FORMULA command, Why the multiplication is performed first rather than parenthesis/bracket ?

Here is a screenshot :

Annotation 2022-09-09 153542.png

 

Please help..??

 

@Excel 

The first operator is + but that is deferred because the next operator * has a higher priority.

The operators / * and - after that first * do not have a higher priority, so that * is evaluated first.

Then the / is evaluated.

Before the second * is evaluated, the expression in parentheses is evaluated. Then the *.

Finally, the + from the beginning, and the last - are evaluated.

Sir what about the Parenthesis...According to PEDMAS Parenthesis comes first and then all remaining operators...Why (4-2) is not performed first?

@Excel 

There is no need to. We can compute 1*16 = 16, then 16/2 = 8, and only then it is necessary to compute (4-2) = 2, so that we can continue with 8*2 = 16. Before we got to that point, it wasn't essential that we compute (4-2).

1 best response

Accepted Solutions
best response confirmed by Excel (Iron Contributor)
Solution

@Excel 

 

Give a try on below sub

Public Sub Information()
ReEnter:
    ' Create inputbox, and (2) asssign value returned by inputbox function to variable
    myInputBoxVariable = InputBox(prompt:="Please enter your PO number", Title:="PO Number")
    
        ' Display message box with value held by varaible
        If IsNumeric(myInputBoxVariable) Then
            MsgBox " Your PO number is:  " & myInputBoxVariable
        Else
            GoTo Incorrect
        End If
    
    ' If error, check with the PO value again
    On Error GoTo Incorrect
    
    Exit Sub
Incorrect:     MsgBox "Please re-enter your PO number"
    GoTo ReEnter
End Sub

View solution in original post