How to Use Boolean Flags in VB

How to Use Boolean Flags in VB thumbnail
Use Boolean flags in your VB program to signal the end of a process.

VB, or Visual Basic, is a programming language from Microsoft, and it has many data types. Textual data is stored in the string data type, numbers in integers and Boolean flags in the Boolean data type. Boolean flags are used in programming to determine the flow through the code. A Boolean flag is set to either "True" or "False." Use the Boolean flag to ensure the variable used for decision making always contains a value expected in your code.

Things You'll Need

  • Visual Basic 6
Show More

Instructions

    • 1

      Click the "Start" button, which is located on the Windows taskbar. Select "Programs," "Microsoft Visual Studio 6.0" and "Microsoft Visual Basic 6.0."

    • 2

      Select "Standard.EXE" on the "New" tab and click the button labeled "Open" to create a new VB 6 application.

    • 3

      Double-click on the text box icon in the tool panel to create "Text1" icon on the form labeled "Form1."

    • 4

      Double-click on the command button icon in the tool panel to create "Command1" icon on the form labeled "Form1."

    • 5

      Double-click on the command button icon in the tool panel to create "Command2" icon on the form labeled "Form1."

    • 6

      Double-click on the window labeled "Form1" to open the code edit window.

    • 7

      Select "General" in the top left drop-down box. Type the following code: "Dim bflag as Boolean."

    • 8

      Select "Command1" in the top left drop-down box and type the following code:

      bflag = True

      Text1.Text = bflag

    • 9

      Select "Command2" in the top left drop-down box and type the following code:

      bflag = False

      Text1.Text = bflag

    • 10

      Press the "F5" key to execute the code in debug mode. Click on the button "Command1" and the text box will display "True," the value of the Boolean flag. Click on the button "Command2" and the text box will display "False," the value of the Boolean flag.

Related Searches:

References

  • "Visual Basic 6 Developer's Handbook"; Evangelos Petroutsos;1999
  • "Mastering Visual Basic 6"; Evangelos Petroutsos;1998
  • Photo Credit Creatas/Creatas/Getty Images

Comments

Related Ads

Featured