Jump to content

If-Then-Change Variable


Recommended Posts

Hello,

i just started a script which should do the following :

1.) inputbox , where u write one of three things ( 1,2,3 )

2.) A If function changes the value of a variable

If $inputbox = "1" then

$Answer = 1

elseif $inputbox = "2" then

$Answer = 2

elseif $inputbox = "3" then

$Answer = 3

3.) Calculate 1 + $Answer and make a massagebox !

Thanks for your Help and Time

Edited by zocker30
Link to comment
Share on other sites

Here is a small example:

$value = InputBox("...", "...")
If Not StringIsInt($value) Then Exit MsgBox(0, "", "No integer given")
MsgBox(0, "", 1 + $value)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

How about this?

Local $inputbox, $Answer

$inputbox = "4" ; <<<<<< change this number to test

Select
Case $inputbox = "1"
  $Answer = 1
  MsgBox(64, "Answer", "Answer = " & $Answer)
Case $inputbox = "2"
  $Answer = 2
  MsgBox(64, "Answer", "Answer = " & $Answer)
Case $inputbox = "3"
  $Answer = 3
  MsgBox(64, "Answer", "Answer = " & $Answer)
Case Else
  MsgBox(64, "Answer", "Unknown Parameter")
EndSelect
Edited by Chimaera
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...