0% found this document useful (0 votes)
1K views5 pages

VB All Assignment

The document contains instructions for 9 programming assignments in Visual Basic.NET. The assignments include: 1. Writing code to display the gender from entered text and changing the background color of a button. 2. Writing code to add two float values together and declare and display a variable for age. 3. Using arrays and loops to display customer names and salaries, and displaying even numbers between 1-100 in a listbox. 4. Creating a multiplication table and code to display student ID, name, and class in a listbox with addition buttons. 5. Getting line counts from a textbox, converting textbox text to uppercase, and copying/pasting text. 6. Code for
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views5 pages

VB All Assignment

The document contains instructions for 9 programming assignments in Visual Basic.NET. The assignments include: 1. Writing code to display the gender from entered text and changing the background color of a button. 2. Writing code to add two float values together and declare and display a variable for age. 3. Using arrays and loops to display customer names and salaries, and displaying even numbers between 1-100 in a listbox. 4. Creating a multiplication table and code to display student ID, name, and class in a listbox with addition buttons. 5. Getting line counts from a textbox, converting textbox text to uppercase, and copying/pasting text. 6. Code for
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment one and two

1. Write a code, which display Gender (use If statement) when if you enter F you have to get Female, M male
and other word Unknown.
If TextBox1.Text = "f" Or TextBox1.Text = "F" Then
TextBox2.Text = "Female"
ElseIf TextBox1.Text = "m" Or TextBox1.Text = "M" Then
TextBox2.Text = "Male"
Else
TextBox2.Text = "Unknown
End If
2. Try to change the background color of the button in your form, with writing a Visual Basic.net code and the
kind of color must be Blue.
* select the button
* then go to properties
*then click backcolor
*then choose the color u want!

3. Write visual basic.net code allow users adding two float value together
Dim number1 As Double
Dim number2 As Double
Dim total As Double
number1 = TextBox1.Text
number2 = TextBox2.Text
total = number1 + number2
TextBox3.Text = total
4. Declare a variable store Age of person.
Dim ag As Integer = 20
MsgBox("Your are " + CStr(ag) + " Years Old")
5. Then the output of the program is (example you are 20 years old)
Dim ag As Integer = 20
MsgBox("Your are " + CStr(ag) + " Years Old")
6. Write a program that display Customer Names and their Salary (use Array and for loop) each customer
Name and his/her salary, must be sequential.
Dim cust(5) As String
Dim sal(5) As Integer
cust(0) = "Mustaf"
cust(1) = "SaidAbubakar"
cust(2) = "Khadija"
cust(3) = "Zahra"
cust(4) = "Jibril"
cust(5) = "Aden"
sal(0) = 10000
sal(1) = 20000
sal(2) = 30000
sal(3) = 40000
sal(4) = 50000
sal(5) = 60000
For i = 0 To cust.Length - 1
MsgBox(cust(i))
MsgBox(sal(i))

7. Display even number in to Listbox for 1 To 100


For i = 0 To 100
If i Mod 2 = 0 Then
ListBox1.Items. Add(i)
End If
Next

8. Create multiplication Time table


Public Class Form1
Dim multiply As Integer = 1
button1 While (multiply <= 12)
ListBox1.Items.Add(multiply & "x" & (TextBox1.Text & "=" & multiply * (TextBox1.Text)))
multiply += 1
End While
button2 Me.Close()
9. Write a code that display the flowing structure, Student Id, Student Name and Student class in a Listbox.
First you must put the Id, Name and Class in a textboxes as the following figure, then click submit button
after that data must be stored in to listbox and clear all textboxes automatically than focus the textbox1.
Delete Button must make deletion data in the Listbox
button1: ListBox1.Items.Add(TextBox1.Text)
ListBox1.Items.Add(TextBox2.Text)
ListBox1.Items.Add(TextBox3.Text
button2: TextBox1.Text = Nothing
TextBox2.Text = Nothing
TextBox3.Text = Nothing
button3 : ListBox1.Items.Clear()
Assignment Three
1. Display the lines in textbox1 in to massage box in Number like (5 lines 12 lines)?
Dim a As Integer = TextBox1.Lines. Length
MsgBox(a & " Lines").
2. Write a lower case into Textbox1 then automatic overwrite into text box2 as upper case?
Dim a As String
a = TextBox1.Text. ToUpper
TextBox2.Text = a
3. Create a code, which make copy and past
My.Computer.Clipboard.SetText("Asc welcome to visual basic .net").
4. Write a program that make size of text, appearance of the text, and Color of the text
Public Class Form1
Dim words As String
button1: words = TextBox1.Text
TextBox2.Text = words
TextBox2.ForeColor = Color.Yellow
Button2: words = TextBox1.Text
TextBox2.Text = words
TextBox2.Font = New Font("Comic Sans Ms", 16, FontStyle.Italic Or FontStyle.Bold)
Button3: words = TextBox1.Text
TextBox2.Text = words
TextBox2.Font = New Font(TextBox2.Font.FontFamily, TextBox2.Font.Size, FontStyle.Bold)
5. Get Location of the specific word.
Dim str As [String] = "Asc welcome visual basic.net Assignment 3"
Dim arr As String() = str.Split(" "c)
MsgBox(Array.IndexOf(arr, "3") + 1)

You might also like