Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 1st, 2008, 08:38 PM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default 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
Reply
  #2  
Old September 1st, 2008, 08:56 PM
YarrOfDoom's Avatar
The Pretender
 
Join Date: Aug 2007
Location: Steenokkerzeel, Belgium
Age: 15
Posts: 935
Default

Quote:
Originally Posted by lee123
Am I forgetting to do something?
Yes, using the CInt() function on Text1.text and Text3.text.
Hope this helps.
Reply
  #3  
Old September 1st, 2008, 09:39 PM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default

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

lee123
Reply
  #4  
Old September 1st, 2008, 10:09 PM
YarrOfDoom's Avatar
The Pretender
 
Join Date: Aug 2007
Location: Steenokkerzeel, Belgium
Age: 15
Posts: 935
Default

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.
Reply
  #5  
Old September 1st, 2008, 11:10 PM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default

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
Reply
  #6  
Old September 2nd, 2008, 07:59 AM
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,283
Default

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
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles