## SpnIslander

Hi All,
Pls help to correct my code below.
how the Else statement work? i can't get the correct answer it's alway the IF statement is evaluated.tks.

Private Sub txtPrice_Change()

Dim intVal As Integer

If Val(txtQty.Text) >= 0 Then
lblVal.Caption = Val(txtPrice.Text)
Else
lblVal.Caption = Val(txtQty.Text) * Val(txtPrice.Text)

End If

End Sub

## venkatramasamy 1

HI,

No problem in the code u provided thewith, it works properly,

the else stament works if the val(Qtytxt).text is< 0...

logically quantity cannot be in <0 zero...

so the problem is with the logic u implemented,

If u need help clearly mention the problem in deatil

With regards
Venkatramasamy SN

## SpnIslander

Thank you Venkatramasamy for taking a look @ my problem. i want to get the value of below 2 diff computation everytime the user enter the data.
1) If txtQty<=0, i need to get the value of txtPrice and put on lblVal.
2) txtQty*txtPrice, i need to get the value of the multiplication and put on lblVal.

hope this is clear if not jst send me a msg and will try again to explain.

## Jx_Man 987

if val(txtQty) >= 0 then
lblVal.caption = val(txtPrice.text)
Else
lblVal.caption = val(txtPrice.text) * val(txtQty.text)
end if

hmm i m confused friend...
what exactly the condition.
1. if Qty >= 0, display price on label val
* what Qty is? quantity??
2. Else
lblVal.caption = val(txtPrice.text) * val(txtQty.text)
* this code means Qty < 0!!, so why you get multiply it with price. absolutely the value of multiplication is zero(0).

## venkatramasamy 1

Hi,

if the quantity is 0 then put the price pnly in the label box
esle
multiply the Price with quantity then place the value in label right if so...

try the following code.,

``````if val(txtQty) > 0 then
lblVal.caption = val(txtPrice.text) * val(txtQty.text)
Else
lblVal.caption = val(txtPrice.text)
end if``````