Basic Operators and Variable in Visual Basic
Method helpers
Goal
• Create a calculator form
• Code and declare variables, operators used
and method helper
• Run code
• ButtonClicked – triggers button to perform its tasks
• GetInput - Helper method to retrieve and convert input from textboxes to
integer
• .Clear()- method helpers that clear the txtbox.
Challenge
• Each button must function according to is functionality
• Use GetInput method to retrieve integer from textbox
• Tryparse Integer helper to convert string representation of a number to its
32-bit signed integer equivalent.
Sample Code
‘Add more for the other buttons’
‘This is the end class’
Passing Value using Get
• fullName – Textbox
• Gender – RadioButton
• Hobbies- Checkbox ()
• Nationality – ComboBox()
• Skills-CheckList()
• Bio(RichText)
• ProfilePicture(PictureBox)
• Address(ListBox)
• Age- NumericUpDown
• Favorate BrowserWeb
• Birthday: Date Picker
How to pass the value?
Provide the necessary details
in the form
Declare variables as you submit the button
Dim f2 As New Form2()//method to instantiate form2
' Set public properties to pass values
[Link] = Name
[Link] = Age
[Link] = Nationality
[Link] = Skills
[Link] = Hobbies
[Link] = Address
[Link] = Country
[Link] = Language
[Link] = Gender
[Link] = Bio
Dispay Form in Form2 the inputted details
• Public Property NameValue As String
• Public Property AgeValue As String
• Public Property NationalityValue As String
• Public Property SkillsValue As String
• Public Property HobbiesValue As String
• Public Property AddressValue As String
• Public Property CountryValue As String Private Sub Form2_Load(sender As Object, e As EventArgs) Handles
• Public Property LanguageValue As String [Link]
• Public Property GenderValue As String
' Display the passed values in labels
[Link] = "Name: " & NameValue
• Public Property BioValue As String [Link] = "Age: " & AgeValue
[Link] = "Nationality: " & NationalityValue
[Link] = "Skills: " & SkillsValue
[Link] = "Hobbies: " & HobbiesValue
[Link] = "Address: " & AddressValue
[Link] = "Country: " & CountryValue
[Link] = "Language: " & LanguageValue
[Link] = "Gender: " & GenderValue
[Link] = "Bio: " & BioValue
End Sub