Computer Science Canada

Help VB thinks "75" is smaller than 25

Author:  Adalias [ Mon Jun 11, 2007 12:25 pm ]
Post subject:  Help VB thinks "75" is smaller than 25

I have an if structure that looks like:
code:

If BuyorSell <> 1 Then
    If Int(lblCash.Caption / SelectedPrice) > Units Then
        txtunits.Text = Units
    Else
        txtunits.Text = Int(lblCash.Caption / SelectedPrice)
    End If
ElseIf BuyorSell = 1 Then
    If Int(cash / SelectedPrice) >= Units Then
        txtunits.Text = Units
    ElseIf Int(cash / SelectedPrice) < Units Then
        txtunits.Text = Int(cash / SelectedPrice)
    End If
End If

Don't worry about most of it, BuyorSell = 1 so its the last part of the first If.
Int(cash/SelectedPrice) claims it = 75 and Units = "25" but it passes that section
and goes to the elseif Int... < Units which it isn't, but goes into like it was true.
I think the problem is that 'Int... = 75' and 'Units="25"' with the quotes there.
If anyone can confirm this and maybe have a solution on how I can set units = 75 without quotes
Incase you need to know, I'm setting units to be the caption of an object in another form.

Author:  cool dude [ Mon Jun 11, 2007 1:25 pm ]
Post subject:  Re: Help VB thinks "75" is smaller than 25

wow i must have read that like 10 times. you need to explain a lot more clearer than that to get any help.

Now what you should be doing is setting that label box to a variable.

for example:

code:
Dim cash as integer
cash = lblCash.caption


This will get rid of the quotes and now it should work fine.


: