"Derivative Calculator" Question

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1100 Views - Last Post: 15 December 2013 - 04:31 AM Rate Topic: -----

#16 Minimalist  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 103
  • Joined: 13-November 13

Re: "Derivative Calculator" Question

Posted 15 December 2013 - 04:31 AM

You have to decide what kind of output you want. A simple example like y= mx^n will either return a string in the form of y= m*n * x^n-1 with n and m numbers or it returns a number of the form y= N. For the first case I have attached some code:
Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       
    End Sub

    Private Sub cmdExit_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub

    Private Sub cmdCalculate_Click(sender As Object, e As EventArgs) Handles cmdCalculate.Click
        Dim dbInputn, dbInputm, dbInputx As Double
        Dim txtInput As String = ""
        'y=mx^n
       
        If TextBox1.Text = "" Or TextBox2.Text = "" Then
            MsgBox("Input missing")
            Exit Sub
        End If
        dbInputn = CDbl(TextBox1.Text) ' input for n
        dbInputm = CDbl(TextBox2.Text) 'input for m
        If TextBox3.Text = "" Then
            TextBox3.Text = "x"
        Else
            dbInputx = CDbl(TextBox3.Text)  'input for x
        End If
        Me.Text= "y =" &  dbInputm & " x ^ " & dbInputn
        Dim intCase As Integer = 0
        If TextBox3.Text = "x" Then
            intCase = 1
        End If
        Dim m, n As Double
        Select Case intCase
            Case 1
                n = dbInputn - 1
                m = dbInputm * dbInputn
                Label4.Text = "y = " & m & " x ^" & n

        End Select
    End Sub
End Class


It looks like this:

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2