Question? Leave a message!




Visual Basic Programming

Visual Basic Programming 32
EdenKelly Profile Pic
EdenKelly,United States,Professional
Published Date:12-07-2017
Website URL
Comment
An Introduction Visual Basic ProgrammingHProgramming for the Windows User Interface is extremely complicated. HOther Graphical User Interfaces (GUI) are no better. HVisual Basic provides a convenient method for building user interfaces. HVisual Basic can interface with code written in C, for efficiency. Why Visual Basic?HVisual Basic is not, a powerful programming language that enables you to do anything you want. HVisual Basic is not, elegant or fast. HVisual Basic is not, a replacement for C. HVisual Basic is not, anything like any other programming language you have ever used. What Visual Basic is notHYou draw pictures of your user interface. HYou draw buttons, text boxes, and other user-interface items. HYou add little snippets of code to handle the user interaction. HYou add initialization code, usually as the last step. HIf you like, you can code more complex functions. (But many do not.) When You Program in VB:Here Program Draw Your The Visual Basic InterfaceSelect A Control From Here Then Draw the control on the form (Click on the appropriate button) Drawing The ProgramPictures Group Box Editable Text Check Box Button Scroll Bar Drop-Down List List Scroll Bar Drive List Pictures Lines And the List Goes On and On ... Data Base Access File List Circles and Stuff Folder Hierarchy Timer Radio Button Static Text Types of ControlsAdd Code Change Properties Using controls: Editable Text Buttons Static Text Select and Single-Click to Double-Click to A Simple ProgramControl Menu. Select New Value From Type In New Value, or Click on Property, and For Currently Selected List of Properties The Properties WindowControl The Body Yourself What to Do When It Happens You must Write NameName External Event Adding CodeHComplex Controls Have: – Action – Active – H Examples: –Spreadsheets – – Web Browsers Word Processors Many Types of Events for Program Interaction Values Are Assigned to Them Properties that Cause Actions When Properties to Execute Commands More Complex ControlsHWrite a DLL in C HUse the _export Property on Appropriate Functions HWrite Visual Basic Definitions for each Function HAdd VB Definitions to The (general) section of the VB Program HUse Functions as if they were VB functions Using C CodeC: long FAR PASCAL _export HexToLong (char Hex) VB: Declare Function HexToLong Lib “ FIRSTONE.DLL” (ByVal InString As String) As Long Argument Name in VB is arbitrary. The Lib keyword Must Give The Name of the Library. Function Name Must Be The Same in Both Declarations. C Definition vs. VB DefinitionHIt is sometimes difficult for VB to FIND the .DLL file. HIf this occurs, copy the .DLL file to the WINDOWS directory. HRemember to Delete the file when you are done. A (Very Annoying) ProblemH Some Versions of VB do not allow DLL function definitions in the (general) section of a form. HTo Get Around this Problem, Create a new Module (File Menu) HAdd the declarations to the (general) section of the module HYou can add your own VB functions to the (general) section of a form or a module. Alternative MethodsHAll Functions are Global in VB HVariables are declared using the syntax: – – –Dim A,B,C As Type will work, but gives HMost Common Types: Integer, String, Long weird results Every variable must have a type Dim Name As Type Syntax ConsiderationsHUse Integers for Booleans –As in C, 0 = False, everything else = True – – HAssignments are the same as in C HThe Val function converts strings to integers HThe Format function converts integers to strings True = -1, False = 0 Symbolic constants True and False may be used More VB SyntaxHAssignments are the Same as in C HCase is not significant – – HThe Usual Operators can be used –AND is the same as both & and && depending – – NOT = OR = and on context For Variable Names, Case is ignored Case will be adjusted for you on keywords VB Statements List of Statements List of Statements Else List of Statements Comparators: =,, , =, =, (not equal) Connectives: And, Or, Not DON’T FORGET THE ENDIF EndIf EndIf If condition ThenIf condition Then VB IF StatementsWhile condition do List of Statements The VB Manual Recommends a different structure. Use the alternative if you wish. Wend VB While Statements