mathmatical signs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    mathmatical signs

    how do you do this:

    in fractions they have a numerator & denominator. Ok I'm making a fraction project and i can't get this to work:

    i have four textboxes two of them are numerators and the other two are Denomiators and a label in my code i want to say:

    Code:
    IF  Text1.text <  Text3.text  Then
          label1.caption = "Proper Fraction"
    End IF
    But when i enter in a number like 50 in the text1 and a 100 in the Text3 the Label doesn't show the Caption.

    But when i enter in a number like 5 in the text1 and a 10 in the text3 the Caption "Proper Fraction" displays.

    Why Is that? How can i get it to show when the number (text1) is less than the Number (text3) when I Have Numbers like that. Am I forgetting to do something?

    lee123
  • YarrOfDoom
    Recognized Expert Top Contributor
    • Aug 2007
    • 1243

    #2
    Originally posted by lee123
    Am I forgetting to do something?
    Yes, using the CInt() function on Text1.text and Text3.text.
    Hope this helps.

    Comment

    • lee123
      Contributor
      • Feb 2007
      • 556

      #3
      I have never used this function before explain more please..

      lee123

      Comment

      • YarrOfDoom
        Recognized Expert Top Contributor
        • Aug 2007
        • 1243

        #4
        The expression you put between the brackets gets converted to an integer.
        Even if Text1is filled in with only numbers, Text1.text returns a string,and CInt() will set this straight. If a non-numeral character is in this string, the function shall return 0. CInt() doesn't only work with strings, but also with other types of data.

        Comment

        • lee123
          Contributor
          • Feb 2007
          • 556

          #5
          ok i have changed the names But this is what i think your saying (please correct me if I'm wrong):

          Code:
          Private Sub Num1_LostFocus()
          If CInt(Num1) < CInt(Num2) Then
              Label3.Caption = "<-- Proper Fraction"
              Label3.FontBold = True
              Label3.FontSize = 18
              Num2.FontSize = 40
          End If
          End Sub
          lee123

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Hi,

            You need to take care of Initialising the label..
            Also use VAL function instead of Int.. CINt causes error if > 32k

            [code=vb]
            Private Sub Num1_LostFocus( )
            If Val(Num1) < Val(Num2) Then
            Label3.Caption = "<-- Proper Fraction"
            Label3.FontBold = True
            Label3.FontSize = 18
            Num2.FontSize = 40
            Else
            Label3.Caption = "<-- ImProper Fraction"
            End If
            End Sub
            [/code]

            Also write the same code in Num2_Lostfocus. .

            Regards
            Veena

            Comment

            Working...