Program to convert the Case of a String in VB.NET

Mid() in Visual Basic.net is a string function that is used to extract a copy of                                     a character or set of characters from a string.

Syntax:
Function Mid( ByVal Str As String, ByVal Start As Integer,
Optional ByVal Length As Integer) As String

In the above syntax Str specifies the string from which the characters to be extracted from the starting position specified using Start, until the specifed Length of characters.

Program UI:

Screenshot (18).png

Program Code:

Public Class Task2

Private Sub btnoutput_Click(sender As Object, e As EventArgs) Handles btnoutput.Click
Dim len, i As Integer
Dim s, c As String
s = Textname.Text
len = s.Length
For i = 1 To len
c = Mid(s, i, 1)
If Asc(c) > 90 And Asc(c) < 123 Then
Textoutput.AppendText(UCase(c))
Else
Textoutput.AppendText(LCase(c))
End If
Next
End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
Textname.Clear()
Textoutput.Clear()
End Sub
End Class

Output:

Screenshot (17).png

Program to find the Case of a Chatacter in VB.NET

In this Program we are going to enter a Character and Display the CASE of the Character on Button Click on TextBox.

Program UI:

Screenshot (19)

Program Code :

Public Class Programmingfromscratch
Dim c As Integer

Private Sub btncheck_Click(sender As Object, e As EventArgs) Handles btncheck.Click
c = Asc(Textchar1.Text)
If (c >= 64 And c <= 91) Then  ‘ASCII VALUE
Textchar2.Text = “UPPER”
ElseIf (c >= 96 And c <= 122) Then
Textchar2.Text = “LOWER”
Else
Textchar2.Text = “Other Character”
End If

End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click 
Textchar2.Text = “”
Textchar1.Text = “”
End Sub

End Class

Output:

Screenshot (20)

Program to check whether a character is vowel or not in VB.NET

In this program we are going to check whether a character is vowel or not and display the result in a Label(i.e label3)  on Button Click

Program UI:

Screenshot (15)

Program Code:

Public Class programmingfromscratch
Dim a As Char

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
a = UCase(TextBox1.Text)
If a = “A” Or a = “E” Or a = “I” Or a = “O” Or a = “U” Then
Label3.Text = “Vowel”
Else
Label3.Text = “Not Vowel”
End If
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Label3.Text = “”
TextBox1.Text = “”

End Sub

End Class

 

Output:

Screenshot (16).png

Program to implement calculator in VB.NET

Program UI:

Screenshot (13)

Program Code :

Public Class calculator
Dim a As Double
Dim b As Double
Dim c As String
Dim f As Integer
Dim d As Integer

Private Sub Numer1_Click(sender As Object, e As EventArgs) Handles Numer1.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “1”
Else
TextBox1.Text += “1”
End If
f = 0
d = 0

End Sub

Private Sub Numer2_Click(sender As Object, e As EventArgs) Handles Numer2.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “2”
Else
TextBox1.Text += “2”
End If
f = 0
d = 0
End Sub

Private Sub Numer3_Click(sender As Object, e As EventArgs) Handles Numer3.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “3”
Else
TextBox1.Text += “3”
End If
f = 0
d = 0
End Sub

Private Sub Numer4_Click(sender As Object, e As EventArgs) Handles Numer4.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “4”
Else
TextBox1.Text += “4”
End If
f = 0
d = 0
End Sub

Private Sub Numer5_Click(sender As Object, e As EventArgs) Handles Numer5.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “5”
Else
TextBox1.Text += “5”
End If
f = 0
d = 0
End Sub

Private Sub Numer6_Click(sender As Object, e As EventArgs) Handles Numer6.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “6”
Else
TextBox1.Text += “6”
End If
f = 0
d = 0
End Sub

Private Sub Numer7_Click(sender As Object, e As EventArgs) Handles Numer7.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “7”
Else
TextBox1.Text += “7”
End If
f = 0
d = 0
End Sub

Private Sub Numer8_Click(sender As Object, e As EventArgs) Handles Numer8.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “8”
Else
TextBox1.Text += “8”
End If
f = 0
d = 0
End Sub

Private Sub Numer9_Click(sender As Object, e As EventArgs) Handles Numer9.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “9”
Else
TextBox1.Text += “9”
End If
f = 0
d = 0
End Sub

Private Sub Numer0_Click(sender As Object, e As EventArgs) Handles Numer0.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “0”
Else
TextBox1.Text += “0”
End If
f = 0
d = 0
End Sub

Private Sub Dot_Click(sender As Object, e As EventArgs) Handles Dot.Click
If d = 1 Then
TextBox1.Text = “”
End If
If f = 1 Then
TextBox1.Text = “”
End If
If TextBox1.Text = “” Then
TextBox1.Text = “.”
Else
TextBox1.Text += “.”
End If
f = 0
d = 0
End Sub

Private Sub Bmod_Click(sender As Object, e As EventArgs) Handles Bmod.Click
a = TextBox1.Text
c = “mod”
d = 1
End Sub

Private Sub Add_Click(sender As Object, e As EventArgs) Handles Add.Click
a = TextBox1.Text
c = “add”
d = 1
End Sub

Private Sub min_Click(sender As Object, e As EventArgs) Handles min.Click
a = TextBox1.Text
c = “min”
d = 1
End Sub

Private Sub mul_Click(sender As Object, e As EventArgs) Handles mul.Click
a = TextBox1.Text
c = “mul”
d = 1
End Sub

Private Sub div_Click(sender As Object, e As EventArgs) Handles div.Click
a = TextBox1.Text
c = “div”
d = 1
End Sub

Private Sub equal_Click(sender As Object, e As EventArgs) Handles equal.Click
b = TextBox1.Text
f = 1
If c = “add” Then
TextBox1.Text = a + b
End If
If c = “min” Then
TextBox1.Text = a – b
End If
If c = “mul” Then
TextBox1.Text = a * b
End If
If c = “div” Then
TextBox1.Text = a / b
End If
If c = “mod” Then
TextBox1.Text = a Mod b
End If

End Sub

Private Sub Clear_Click(sender As Object, e As EventArgs) Handles Clear.Click
a = 0
b = 0
TextBox1.Text = “”
End Sub
End Class

Screenshot (14)

 

Program to add two numbers in VB.NET

In this program we will take two numbers as input in TextBox and display the addition of numbers in a MessageBox on Button Click.

Program UI:

Screenshot (10).png

Program Code:

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim num1 As Double
Dim num2 As Double
num1 = TextBox1.Text
num2 = TextBox2.Text
MessageBox.Show(“Addition :” + (num1 + num2).ToString)

‘coversion of double value to string

End Sub
End Class

Output:

Screenshot (11).png

Program to display content of textbox using button in vb.net

In this program we are going to display the content of Textbox on a Label on Button Click.

Program UI :

Screenshot (8).png

Program Code:

Public Class programmingfromscratch

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label3.Text = “Hello, ” + TextBox1.Text + ” You Study in ” + TextBox2.Text + “!”

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Label3.Text = “” ‘
End Sub

End Class

Output:

Screenshot (9).png