title: Implementing custom classes
body: <p>I've got this code and it works, though I'm confused as to how I'm supposed to implement a custom class. The operators need to be changed and I've put together everything I've learned and been helped with so far and have this as the Class. I'm trying to change the operators into a custom class, so instead of +,-,*,/, I would use something else. Basically this is the class, and below that the full code</p>
  
  <pre><code>Public Class MathOp
      Public Function Add(NumOne As Integer, NumTwo As Integer) As Integer
          Return NumOne + NumTwo
      End Function
  
      Public Function Subtract(NumOne As Integer, NumTwo As Integer) As Integer
          Return NumOne - NumTwo
      End Function
  
  End Class
  
  
  Public Class MathOp2
  Inherits MathOp
  
  Public Function Mul(value1 As Integer, value2 As Integer) As Integer
      Return value1 * value2
  End Function
  
  Public Function Div(value1 As Integer, value2 As Integer) As Integer
      Return value1 / value2
  End Function
  
  End Class
  </code></pre>
  
  <p>And I've put together this code, which works as long as the standard operators are used. I just don't know what I'm supposed to do next.</p>
  
  <pre><code>Option Explicit On
  Option Strict On
  Option Infer Off
  
  
  
  Public Class Form1
  
  
  
  Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles m3.Click
      'Adds the numbers together and the tag remembers the operator
  
     Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles m3.Click
      'Adds the numbers together and the tag remembers the operator
  
      Dim m As New MathOp()
      Dim R As Integer = m.Add(CInt(NumOne.Text), CInt(NumTwo.Text))
  
  
      If NumOne.Text = ("") Then
          MessageBox.Show("Please enter the first number")
          NumOne.Focus()
      ElseIf NumTwo.Text = ("") Then
          MessageBox.Show("Please enter the second number")
          NumTwo.Focus()
      End If
  
      Result.Text = CStr(m.Add(CInt(NumOne.Text), CInt(NumTwo.Text)))
  
      ListBox1.Tag = "+"
  
  
  
  End Sub
  
  Private Sub ButtonSub_Click(sender As Object, e As EventArgs) Handles ButtonSub.Click
      'Subtracts the numbers
  
      If NumOne.Text = ("") Then
          MessageBox.Show("Please enter the first number")
          NumOne.Focus()
      ElseIf NumTwo.Text = ("") Then
          MessageBox.Show("Please enter the second number")
          NumTwo.Focus()
      End If
      Result.Text = CStr(Val(NumOne.Text) - Val(NumTwo.Text))
      ListBox1.Tag = "-"
  End Sub
  
  Private Sub ButtonMul_Click(sender As Object, e As EventArgs) Handles ButtonMul.Click
      'Multiplies the numbers
  
      If NumOne.Text = ("") Then
          MessageBox.Show("Please enter the first number")
          NumOne.Focus()
      ElseIf NumTwo.Text = ("") Then
          MessageBox.Show("Please enter the second number")
          NumTwo.Focus()
      End If
  
      Result.Text = CStr(Val(NumOne.Text) * Val(NumTwo.Text))
      ListBox1.Tag = "x"
  End Sub
  
  Private Sub ButtonDiv_Click(sender As Object, e As EventArgs) Handles ButtonDiv.Click
      'Divides the numbers, with a divide by 0 exception
  
      If NumOne.Text = ("") Then
          MessageBox.Show("Please enter the first number")
          NumOne.Focus()
      ElseIf NumTwo.Text = ("") Then
          MessageBox.Show("Please enter the second number")
          NumTwo.Focus()
      End If
  
  
  
  
      Result.Text = CStr(Val(NumOne.Text) / Val(NumTwo.Text))
      ListBox1.Tag = "/"
  
      'outputs a message box telling the user to correct the division by 0, also displays a blank result box instead of NaN
  
      Try
  
          If CDbl(NumTwo.Text) = Val(0) Then
              Result.Text = ""
              MessageBox.Show("You cannot divide by 0, please input another number")
              NumTwo.Focus()
          End If
  
      Catch ex As Exception
          Result.Text = ""
  
      End Try
  
  End Sub
  
  Private Sub ButtonExit_Click(sender As Object, e As EventArgs) Handles ButtonExit.Click
      'Simply closes the form
      Me.Close()
  End Sub
  
  Private Sub ButtonSave_Click(sender As Object, e As EventArgs) Handles ButtonSave.Click
  
      If NumOne.Text = ("") Then
          MessageBox.Show("Please enter some numbers")
          NumOne.Focus()
      ElseIf NumTwo.Text = ("") Then
          MessageBox.Show("Please enter another number")
          NumTwo.Focus()
      End If
  
      Try
          If ListBox1.Items.Count &lt; 10 Then
              ListBox1.Items.Add(NumOne.Text &amp; ListBox1.Tag.ToString() &amp; NumTwo.Text &amp; ("=") &amp; Result.Text)
          End If
      Catch ex As Exception
          Result.Text = ""
  
      End Try
  End Sub
  
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles ButtonClear.Click
      ListBox1.Items.Clear()
  End Sub
  
  
  Private Sub ButtonReset_Click_1(sender As Object, e As EventArgs) Handles ButtonReset.Click
      NumOne.Text = ""
      NumTwo.Text = ""
      Result.Text = ""
  End Sub
  
  
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Dim toolTip1, toolTip2, toolTip3, toolTip4, toolTip5, toolTip6, toolTip7, toolTip8 As New ToolTip()
  
      toolTip1.SetToolTip(Me.m3, "Addition")
      toolTip2.SetToolTip(Me.ButtonSub, "Subtraction")
      toolTip3.SetToolTip(Me.ButtonMul, "Multiplication")
      toolTip4.SetToolTip(Me.ButtonDiv, "Division")
      toolTip5.SetToolTip(Me.ButtonSave, "Save operation")
      toolTip6.SetToolTip(Me.ButtonReset, "Reset operation")
      toolTip7.SetToolTip(Me.ButtonExit, "Exit application")
      toolTip8.SetToolTip(Me.ButtonClear, "Clear list")
  
  
  
  
  End Sub
  
  Private Sub ListBox1_DoubleClick(sender As Object, e As EventArgs) Handles ListBox1.DoubleClick
  
  
      'This is part of the second assignment, double click on list items and they show up in the text boxes, still working on the other part
  
      If ListBox1.SelectedIndex = -1 Then
          Return
      End If
  
      'Get the text of the selected item
      Dim selectedtext As String = ListBox1.Items(ListBox1.SelectedIndex).ToString()
  
      'Split the item by the operator and the = into an array of strings
      Dim parts As String() = selectedtext.Split("+"c, "-"c, "x"c, "/"c, "="c)
  
      If parts.Length &gt; 2 Then
          'Define a variable for each part
          Dim part1 As String = parts(0).Trim()
          Dim part2 As String = parts(1).Trim()
  
          NumOne.Text = part1
          NumTwo.Text = part2
  
          'Make text boxes set to part1 and part2. part1 = 1, part2 = 1
      End If
  
  End Sub
  End Class
  </code></pre>