Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Trouble with strings

$
0
0
Thank you. I know what you guys are saying but I guess my example was too simple. I am making a graphing calculator and one of the parts of the program requests the user to insert his/her function.

Private Sub Y1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Y1ToolStripMenuItem.Click
        Dim y1 As String
        Dim newy1 As String
        Dim functiondraw As Graphics = Me.CreateGraphics

        y1 = InputBox("Enter the function you wish to graph. For sin write math.sin, for cos write math.cos, for tan write math.tan etc. For the variable use x. If you wish to indicate multiplication, use * or grouping symbols. To add write +, to subtract write - to divide write /", "Enter function")

        For j As Integer = 0 To 20
            Dim xcord As Integer = -1 * scale
            xcord += j * (scale / 10)
            newy1 = y1.Replace("x", xcord)

        Next

    End Sub


that is what it looks like. The idea is to plot different points using the different values of x. Disregard the 20 and 10 and other things, they are there for other reasons. The problem arises because the user inputs a function which is a string. I change the "x"'s to x values and then expect to get a y value. However, it does not work. Would this parse thing work? I really don't want to write thousands of cases for each possible character in the function. Any ideas?

Viewing all articles
Browse latest Browse all 51036

Trending Articles