daohieu61

Need help with Multivariable

5 posts in this topic

I want to write a script that read thing in a textbox and use the text to calculate  "a2  " but instead of reading only one number, i want the script to read several numbers seperated by semicolon ";" or  comma "," and show the result by execute the script with each numbers sequentially . This is the example script:

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateInput("a", 88, 42, 60, 21)
Global $Solve = GUICtrlCreateButton("Solve", 160, 42, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            Equation(GUICtrlRead($Input1))
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc


 

Share this post


Link to post
Share on other sites



Something like this:

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateInput("a", 88, 42, 60, 21)
Global $Solve = GUICtrlCreateButton("Solve", 160, 42, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            $result = StringSplit(GUICtrlRead($Input1),",;")
            for $x = 1 to $result[0]
                Equation($result[$x])
            Next
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
    MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
3 minutes ago, Jos said:

Something like this:

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateInput("a", 88, 42, 60, 21)
Global $Solve = GUICtrlCreateButton("Solve", 160, 42, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            $result = StringSplit(GUICtrlRead($Input1),",;")
            for $x = 1 to $result[0]
                Equation($result[$x])
            Next
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
    MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc

Jos

Thank you very much. I have a script with a bigger input box but my text is alway show on first line. I want it to auto word wrap (like word) but i don't know how to do. Can you help me again pls?

Share this post


Link to post
Share on other sites

Sure, that shouldn't be that difficult:

#include <EditConstants.au3>

Global $Form1 = GUICreate("Test", 250, 137, 181, 124)
Global $Label1 = GUICtrlCreateLabel("Number", 18, 44, 45, 27)
Global $Input1 = GUICtrlCreateEdit("a", 88, 42, 120, 60,$ES_MULTILINE)
Global $Solve = GUICtrlCreateButton("Solve", 160, 112, 80, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Solve
            $result = StringSplit(GUICtrlRead($Input1),",;")
            for $x = 1 to $result[0]
                Equation($result[$x])
            Next
    EndSwitch
WEnd

Func Equation($example)
    $a= $example^2
    MsgBox ( 48, "solution", "The solution of " & $example & "^2 is " & $a)
EndFunc

Jos

PS:No need to qoute my post as we can see what I wrote already ;) 

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thank you very much:D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now