Public Class Form1 Private Sub llSc_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles llSc.LinkClicked Dim cdg As New ColorDialog If cdg.ShowDialog() = DialogResult.OK Then End If BackColor = cdg.Color End Sub Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click txtExp.Text = txtInput.Text & "+" If txtExp.Text = "-" Then txtExp.Text = txtInput.Text & " - " ElseIf txtExp.Text = "/" Then txtExp.Text = txtInput.Text & "/" ElseIf txtExp.Text = "*" Then txtExp.Text = txtInput.Text & "*" End If txtInput.Clear() End Sub Private Sub btnSub_Click(sender As Object, e As EventArgs) Handles btnSub.Click txtExp.Text = txtInput.Text & "-" 'txtInput.Clear() If txtExp.Text = "-" Then txtExp.Text = txtInput.Text & " - " ElseIf txtExp.Text = "/" Then txtExp.Text = txtInput.Text & "/" ElseIf txtExp.Text = "*" Then txtExp.Text = txtInput.Text & "+" End If txtInput.Clear() End Sub Private Sub btnMulti_Click(sender As Object, e As EventArgs) Handles btnMulti.Click txtExp.Text = txtInput.Text & "*" 'txtInput.Clear() If txtExp.Text = "-" Then txtExp.Text = txtInput.Text & " - " ElseIf txtExp.Text = "/" Then txtExp.Text = txtInput.Text & "/" ElseIf txtExp.Text = "+" Then txtExp.Text = txtInput.Text & "*" End If txtInput.Clear() End Sub Private Sub btnDiv_Click(sender As Object, e As EventArgs) Handles btnDiv.Click txtExp.Text = txtInput.Text & "/" 'txtInput.Clear() If txtExp.Text = "-" Then txtExp.Text = txtInput.Text & " - " ElseIf txtExp.Text = "+" Then txtExp.Text = txtInput.Text & "+" ElseIf txtExp.Text = "*" Then txtExp.Text = txtInput.Text & "*" End If txtInput.Clear() End Sub Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click txtInput.Text = "" txtExp.Text = "" txtAns.Text = "" End Sub Private Sub btnEqual_Click(sender As Object, e As EventArgs) Handles btnEqual.Click Try Dim exp As String = txtExp.Text Dim ans As Object = New DataTable().Compute(exp, Nothing) txtAns.Text = ans.ToString() Catch ex As Exception End Try End Sub Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click Try Dim currentInput1 As String = txtExp.Text Dim currentInput2 As String = txtInput.Text If currentInput1 <> "" Then txtExp.Text = currentInput1 End If If currentInput2 <> "" Then txtInput.Text = currentInput2 End If Catch ex As Exception End Try End Sub Private Sub txtSrwe_TextChanged(sender As Object, e As EventArgs) Handles txtSrwe.TextChanged txtSrwe1.Text = CInt(txtSrwe.Text) * (2.5) If txtSrwe1.Text >= 0 And txtSrwe1.Text <= 40 Then txtGs.Text = "F" ElseIf txtSrwe1.Text >= 41 And txtSrwe1.Text <= 60 Then txtGs.Text = "C" ElseIf txtSrwe1.Text >= 61 And txtSrwe1.Text <= 69 Then txtGs.Text = "B" ElseIf txtSrwe1.Text >= 70 And txtSrwe1.Text <= 79 Then txtGs.Text = "B+" ElseIf txtSrwe1.Text >= 80 And txtSrwe1.Text <= 100 Then txtGs.Text = "A" End If End Sub Private Sub txtDbp_TextChanged(sender As Object, e As EventArgs) Handles txtDbp.TextChanged txtDbp1.Text = CInt(txtDbp.Text) * (2.5) If txtDbp1.Text >= 0 And txtDbp1.Text <= 40 Then txtGd.Text = "F" ElseIf txtDbp1.Text >= 41 And txtDbp1.Text <= 60 Then txtGd.Text = "C" ElseIf txtDbp1.Text >= 62 And txtDbp1.Text <= 69 Then txtGd.Text = "B" ElseIf txtDbp1.Text >= 70 And txtDbp1.Text <= 79 Then txtGd.Text = "B+" ElseIf txtDbp1.Text >= 80 And txtDbp1.Text <= 100 Then txtGd.Text = "A" End If End Sub Private Sub txtAi_TextChanged(sender As Object, e As EventArgs) Handles txtAi.TextChanged txtAi1.Text = CInt(txtAi.Text) * (2.5) If txtAi1.Text >= 0 And txtAi1.Text <= 40 Then txtGa.Text = "F" ElseIf txtAi1.Text >= 41 And txtAi1.Text <= 60 Then txtGa.Text = "C" ElseIf txtAi1.Text >= 62 And txtAi1.Text <= 69 Then txtGa.Text = "B" ElseIf txtAi1.Text >= 70 And txtAi1.Text <= 79 Then txtGa.Text = "B+" ElseIf txtAi1.Text >= 80 And txtAi1.Text <= 100 Then txtGa.Text = "A" End If End Sub Private Sub txtGui_TextChanged(sender As Object, e As EventArgs) Handles txtGui.TextChanged txtGui1.Text = CInt(txtGui.Text) * (2.5) If txtGui1.Text >= 0 And txtGui1.Text <= 40 Then txtGg.Text = "F" ElseIf txtGui1.Text >= 41 And txtGui1.Text <= 60 Then txtGg.Text = "C" ElseIf txtGui1.Text >= 62 And txtGui1.Text <= 69 Then txtGg.Text = "B" ElseIf txtGui1.Text >= 70 And txtGui1.Text <= 79 Then txtGg.Text = "B+" ElseIf txtGui1.Text >= 80 And txtGui1.Text <= 100 Then txtGg.Text = "A" End If End Sub Private Sub txtTot_TextChanged(sender As Object, e As EventArgs) Handles txtTot.TextChanged txtTot1.Text = CInt(txtTot.Text) * (2.5) Dim grade As Integer grade = CInt(txtTot1.Text) * (0.25) If grade >= 0 And grade <= 40 Then txtGtot.Text = "F" ElseIf grade >= 41 And grade <= 60 Then txtGtot.Text = "C" ElseIf grade >= 62 And grade <= 69 Then txtGtot.Text = "B" ElseIf grade >= 70 And grade <= 79 Then txtGtot.Text = "B+" ElseIf grade >= 80 And grade <= 100 Then txtGtot.Text = "A" End If txtGrade.Text = txtGtot.Text End Sub Private Sub txtOriginalText_TextChanged(sender As Object, e As EventArgs) Handles txtOriginalText.TextChanged Dim strtxtOrignalText As String Dim strtxtReverseText As String Dim intCount As Integer strtxtOrignalText = txtOriginalText.Text strtxtReverseText = "" For intCount = Len(strtxtOrignalText) To 1 Step -1 strtxtReverseText = strtxtReverseText & Mid(strtxtOrignalText, intCount, 1) Next intCount txtReverseText.Text = strtxtReverseText End Sub Private Sub txtReverseText_TextChanged(sender As Object, e As EventArgs) Handles txtReverseText.TextChanged Dim strReversedText As String = txtReverseText.Text lstStore.Items.Add(strReversedText) End Sub Private Sub lstStore_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstStore.SelectedIndexChanged lstStore.Items.Add(txtReverseText) End Sub Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click Dim Num As Integer = 1 lst1.Items.Add(Num & "." & vbTab & txtName.Text & vbTab & vbTab & txtSrwe.Text & vbTab & txtDbp.Text & vbTab & txtAi.Text & vbTab & txtGui.Text & vbTab & txtGrade.Text) 'lst1.Items.Add(vbTab & "Name" & vbTab & vbTab & "SWE" & vbTab & "DBF" & vbTab & "AI" & vbTab & "GUI" & vbTab & "Grade") 'lst1.Items.Add("1" & vbTab & txtName.Text & vbTab & vbTab & txtSrwe1.Text & vbTab & txtDbp1.Text & vbTab & txtAi1.Text & vbTab & txtGui1.Text & vbTab & txtGrade.Text) txtName.Clear() txtSrwe1.Clear() txtGs.Clear() txtDbp1.Clear() txtGd.Clear() txtGui1.Clear() txtGg.Clear() txtAi1.Clear() txtGa.Clear() txtTot1.Clear() txtGtot.Clear() txtGrade.Clear() End Sub End Class
Write, Run & Share VB.net code online using OneCompiler's VB.net online compiler for free. It's one of the robust, feature-rich online compilers for VB.net language, running on the latest version 16. Getting started with the OneCompiler's VB.net compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as VB.net
. OneCompiler also has reference programs, where you can look for the sample code to get started with.
OneCompiler's VB.net online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample VB.net program which takes name as input and prints hello message with your name.
Public Module Program
Public Sub Main(args() As string)
Dim name as String = Console.ReadLine() ' Reading input from STDIN
Console.WriteLine("Hello " & name) ' Writing output to STDOUT
End Sub
End Module
Visual Basic is a event driven programming language by Microsoft, first released in the year 1991.
Variable is a name given to the storage area in order to identify them in our programs.
Simple syntax of Variable declaration is as follows
Dim variableName [ As [ New ] dataType ] [ = initializer ]
variableName = value
If condition-expression Then
'code
End If
If(conditional-expression)Then
'code if the conditional-expression is true
Else
'code if the conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
Else If(conditional-expression) Then
'code if the above conditional-expression is true
Else
'code if the above conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
If(conditional-expression)Then
'code if the above conditional-expression is true
End If
End If
Select [ Case ] expression
[ Case expressionlist
'code ]
[ Case Else
'code ]
End Select
For counter [ As datatype ] = begin To end [ Step step ]
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ counter ]
For Each element [ As datatype ] In group
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ element ]
While conditional-expression
'Code
[ Continue While ]
'Code
[ Exit While ]
'Code
End While
Do { While | Until } conditional-expression
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop
Do
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop { While | Until } conditional-expression
Procedure is a sub-routine which contains set of statements. Usually Procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
Procedures are of two types.
Functions return a value when they are called.
[accessModifiers] Function functionName [(parameterList)] As returnType
'code
End Function
Sub-procedures are similar to functions but they don't return any value.
Sub ProcedureName (parameterList)
'Code
End Sub