Jump to content
Xtreme .Net Talk

RBCC

Members
  • Posts

    14
  • Joined

  • Last visited

Personal Information

  • .NET Preferred Language
    VB.net

RBCC's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Dim WithEvents clsfraction As New fraction Dim WithEvents clsfraction1 As New fraction Dim denominator, denominator1 As Int16 Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim common, numer1, numer2, denom, total As Int16 Dim gcd As Int16 'holds value of gcd numer1 = Val(txtnum1.Text) numer2 = Val(txtnum2.Text) denominator = Val(txtdenom1.Text) denominator1 = Val(txtdenom2.Text) common = clsfraction.calculate_common_denominator(denominator, denominator1) total = clsfraction.add(clsfraction, clsfraction1) gcd = clsfraction.reduce(total, common) common = common / gcd total = total / gcd txtsumnum.Text = total txtsumdenom.Text = common End Sub Private Sub clsfraction1_zerodenom() Handles clsfraction1.zerodenom MessageBox.Show("Error-Zero in the denominator") End Sub End Class ;***************Classes****************************** Public Class fraction Dim m_numerator As Int16 Dim m_denominator As Int16 Public Event zerodenom() Public Property numerator() As Int16 Get Return m_numerator End Get Set(ByVal Value As Int16) Value = m_numerator End Set End Property Public Property denominator() As Int16 Get Return m_denominator End Get Set(ByVal Value As Int16) Value = m_denominator End Set End Property Public Function reduce(ByVal numerator As Int16, ByVal denominator As Int16) As Int16 Dim temp As Int16 Do While denominator <> 0 temp = denominator denominator = numerator Mod denominator numerator = temp Loop Return numerator End Function Public Function calculate_common_denominator(ByVal denominator As Int16, ByVal denominator1 As Int16) Dim common As Int16 common = denominator * denominator1 Return common End Function Public Function add(ByVal frac1 As fraction, ByVal frac2 As fraction) Dim sum1, sum2, total As Int16 'How do I pass the numerator and denominator of each fraction?? total = sum1 + sum2 End Function End Class :confused: John
  2. So if had to calculate and output a common denominator in a textbox. ie: Switch the value to the common denominator calcultion I should use a property?
  3. Explain "Side Effects" please!
  4. Without being public how do you call a method with the data from a textbox?
  5. Can you not use a property for a calculation?
  6. how do I use an textbox for input and store it in a arraylist?
  7. I am trying to learn when I should use a method and when should I use property? I am trying to write a one line routine that multiplies 2 denominators of a fraction together. Should I use a method or property I have a class that has the numerator and denominator in it and I would like to know it is good programming practice to do calculations in a property? JOHN :confused: :confused: :confused:
  8. I just found it! John
  9. Double Subscripted Arrays How do I pass a double Subscripted array to a function and retrurn one? I have a routine called private function fill_array(???) how do I pass a double subscripted array to this function??? and how would return one!
  10. RBCC

    Arrays

    I have a 3X3 2 dimensional array and wanted to output the the members of the to a listbox in rows and columns
  11. RBCC

    Arrays

    How do I output an array in a listbox like this? 1 2 2 1 2 3 1 2 3 I just can't figure this one out:confused: John
  12. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub How do I call in the keypress event from the combobox that is on the screen from this code? John
  13. Yes that is what it will do, however I am trying to figure out how to use the keypress event so the program will know when the a keypress happens.
  14. I have a form with a combo box on it called cbojunk, I would like to figure out how to do this: 1. Upon Entry a. in the text portion the person types something in say"Fred" b.if fred is found in the file then it outputs it or <this is what I need help with> A window (msgbox) pops up and says"would you like to Enter the rest of the info" if the user types something, then the code will trap it and pop up the dialog box, how is this done? Is there a website that explains as well as shows this? John :confused:
×
×
  • Create New...