Results 1 to 2 of 2

Thread: Hmmmm how could I describe my problem?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Baexem, Limburg, The Netherlands
    Posts
    5

    Post

    Well, I'm not that of a experienced programmer, but I use VB to implement some Operations Reserach algorithms.

    How can I do the following?

    The user types in a textbox/inputbox some function (like 3*x+5). How can I use this function as an input in the following procedure, let's say:

    Function integrate(?) as Double
    ....
    integrate=area
    End Function

    (for example when you want to numerically integrate this function)

    Any help greatly appreciated...

    Kind regards,

    Gertjan

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    Well, I'm not sure I understand your question, but if you are asking how to pass a string from a textbox to a function, then you would do this:

    Code:
    Option Explicit
    
    'Here is the function
    Private Function Integrate(sInput As String) As Double
       'Here you would have to place complicated code to parse the string, pulling out 
       'numbers and operators. Then you would have to actually perform the calculations
       'and place the result into the function name
    
       Integrate = dResult
    End Function
    
    'Here is where you would call the function using the textbox text
    Private Sub Command1_Click()
       Text2.Text = Integrate(Text1.Text)
    End Sub
    As far as I know there is no easy way to take a string containing a formula and convert it so you can use it for a calculation. You might consider using a calculator control, or just use a text box for numeric input and command buttons with the operators on them as captions, like your own custom calculator.

    Good luck,

    ~seaweed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width