output of experiment no:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · experiment no:1...

25
OUTPUT OF EXPERIMENT NO:1 1

Upload: others

Post on 30-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

 

 

 

OUTPUT OF EXPERIMENT NO:1 

 

 

 

 

 

 

 

 

 

 

 

 

  1 

Page 2: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

EXPERIMENT NO:1

WAP to find the Average, Total Grade of student using if else statements (In Console).

Module Module1 Sub Main() Dim total, avg, per As Double Dim mynumber(4), i As Integer System.Console.WriteLine("Enter the five subject marks of student") For i = 0 To 4 mynumber(i) = Val(System.Console.ReadLine()) total = total + mynumber(i) Next avg = total / 5 per = (total / 500) * 100 System.Console.Write("Average marks of student=") System.Console.WriteLine(avg) System.Console.Write("Grade of Student=") If per < 45 Then System.Console.Write("FAIL") End If If per < 60 And per >= 45 Then System.Console.Write("Grade D") End If If per < 75 And per >= 60 Then System.Console.Write("Grade C") End If If per < 85 And per >= 75 Then System.Console.Write("Grade B") End If If per > 85 Then System.Console.Write("Grade A") End If System.Console.Read() End Sub End Module  

 

 

 

 

 

 

 

 

  2 

Page 3: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

 

 

OUTPUT OF EXPERIMENT NO:2

 

 

 

 

 

 

 

 

 

 

 

 

 

  3 

Page 4: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

          EXPERIMENT NO:2 

WAP to input any number between (0—6) and print appropriate day, week. 

Module Module1 Sub Main() Dim intInput As Integer System.Console.WriteLine("Enter an integer…") intInput = Val(System.Console.ReadLine()) Select Case intInput Case 1 System.Console.WriteLine("Monday") Case 2 System.Console.WriteLine("Tuesday") Case 3 System.Console.WriteLine("Wednesday") Case 4 System.Console.WriteLine("Thursday") Case 5 System.Console.WriteLine("Friday") Case 6 System.Console.WriteLine("Saturday") Case 7 System.Console.WriteLine("Sunday") Case Else System.Console.WriteLine("Invalid! Please Enter Number Between 1 And 7") End Select System.Console.Read() End Sub End Module  

 

 

 

 

 

 

 

 

 

 

  4 

Page 5: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

 

OUTPUT OF EXPERIMENT NO:3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  5 

Page 6: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

        EXPERIMENT NO:3 

Print the pattern Using For loop.

Module Module1 Sub Main() Dim i, j As Integer System.Console.WriteLine("Display Pattern *") For i = 1 To 5 For j = 1 To i System.Console.Write("* ") Next System.Console.WriteLine() Next System.Console.Read() End Sub End Module  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  6 

Page 7: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

 

OUTPUT OF EXPERIMENT NO:4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  7 

Page 8: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

          EXPERIMENT NO:4 

WAP to input numbers in 1D array and print in ascending & descending order.

Module Module1 Sub Main() Dim mynumber(4), i, j, temp As Integer System.Console.WriteLine("Enter the Elements of Array") For i = 0 To 4 mynumber(i) = Val(System.Console.ReadLine()) Next For i = 0 To 4 For j = i + 1 To 4 If mynumber(i) > mynumber(j) Then temp = mynumber(i) mynumber(i) = mynumber(j) mynumber(j) = temp End If Next Next System.Console.WriteLine("Elements of Array in Ascending Order Are:") For i = 0 To 4 System.Console.Write(mynumber(i)) System.Console.Write(" ") Next System.Console.WriteLine() System.Console.WriteLine("Elements of Array in Descending Order Are:") For i = 4 To 0 Step -1 System.Console.Write(mynumber(i)) System.Console.Write(" ") Next System.Console.Read() End Sub End Module  

 

 

 

 

 

 

 

 

 

  8 

Page 9: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

OUTPUT OF EXPERIMENT NO:5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  9 

Page 10: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

      EXPERIMENT NO:5 

WAP to input number in 2D array and perform the following operations  

a) Sum of all number  

b) Forward Diagonal & Backward diagonal  

Module Module1 Sub Main() Dim mat(3, 3), i, j, sum, left, right As Integer System.Console.WriteLine("Enter the Elements of Array") For i = 0 To 3 For j = 0 To 3 mat(i, j) = Val(System.Console.ReadLine()) sum = sum + mat(i, j) Next Next For i = 0 To 3 For j = 0 To 3 If i = j Then left = left + mat(i, j) End If If (i + j) = 3 Then right = right + mat(i, j) End If Next Next System.Console.Write("Sum of Array=") System.Console.WriteLine(sum) System.Console.Write("Sum of forward diagonal=") System.Console.WriteLine(left) System.Console.Write("Sum of Backward diagonal=") System.Console.WriteLine(right) System.Console.Read() End Sub End Module  

 

 

 

 

 

 

 

 

  10 

Page 11: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

 

 

 

 

OUTPUT OF EXPERIMENT NO:6

 

 

 

 

 

 

 

 

 

 

  11 

Page 12: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

      EXPERIMENT NO:6

WAP to input number in 2D array and perform the Sum of two matrices. Module Module1 Sub Main() Dim mata(2, 2), matb(2, 2), matc(2, 2), i, j As Integer System.Console.WriteLine("Enter the Elements of matrix a") For i = 0 To 2 For j = 0 To 2 mata(i, j) = Val(System.Console.ReadLine()) Next Next System.Console.WriteLine("Enter the Elements of matrix b") For i = 0 To 2 For j = 0 To 2 matb(i, j) = Val(System.Console.ReadLine()) Next Next For i = 0 To 2 For j = 0 To 2 matc(i, j) = mata(i, j) + matb(i, j) Next Next System.Console.WriteLine("sum of two matrix =") For i = 0 To 2 For j = 0 To 2 System.Console.Write(matc(i, j)) System.Console.Write(" ") Next Next System.Console.Read() End Sub End Module

  

 

 

 

 

 

 

 

  12 

Page 13: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

OUTPUT OF EXPERIMENT NO:7

 

 

 

 

 

 

 

 

 

 

 

  13 

Page 14: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

        EXPERIMENT NO:7

Design simple calculation to implement Addition, Subtraction and Multiplication and Division.  Public Class Form1 #Region "Dims and other" Dim OperationON As Boolean Dim point As Boolean Dim Firstnum As Double 'optype Dim actIND As OpType Enum OpType NA = 0 Plus = 1 Minus = 2 Multi = 3 Div = 4 Sqr = 5 Root = 6 End Enum #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load point = False actIND = OpType.NA OperationON = False For Each obj As Control In Me.Controls If Mid(obj.ToString, 1, Len("System.Windows.Forms.Button")) = "System.Windows.Forms.Button" Then If Not obj.Name = "SCAPEGOAT" Then AddHandler obj.GotFocus, AddressOf ScapeThis End If End If Next End Sub Private Sub ScapeThis(ByVal Sender As Object, ByVal E As System.EventArgs) SCAPEGOAT.Focus() End Sub Private Sub dot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dot.Click If InStr(txtscreen.Text, ".") = 0 Then point = True End Sub Sub AddSing(ByVal number As Byte) 'clear screen if operation was selected If OperationON = True Then txtscreen.Text = 0 OperationON = False End If 'if to much numbers exit sub, skip adding If InStr(txtscreen.Text, ".") = 0 Then If Len(txtscreen.Text) = 8 Then Exit Sub Else If Len(txtscreen.Text) = 9 Then Exit Sub End If

  14 

Page 15: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

'if screen = zero AND dot not "pressed" clear screen If point = False Then If txtscreen.Text = 0 Then txtscreen.Text = "" Else 'if dot "pressed" add dot and "unpress" dot txtscreen.Text &= "." point = False End If 'add number txtscreen.Text &= number End Sub #Region "Nums" Private Sub num0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num0.Click AddSing(0) End Sub Private Sub num1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num1.Click AddSing(1) End Sub Private Sub num2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num2.Click AddSing(2) End Sub Private Sub num3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num3.Click AddSing(3) End Sub Private Sub num4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num4.Click AddSing(4) End Sub Private Sub num5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num5.Click AddSing(5) End Sub Private Sub num6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num6.Click AddSing(6) End Sub Private Sub num7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num7.Click AddSing(7) End Sub Private Sub num8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num8.Click AddSing(8) End Sub Private Sub num9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num9.Click

  15 

Page 16: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

AddSing(9) End Sub #End Region Private Sub del_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles del.Click 'on press del remove one number from left side txtscreen.Text = Strings.Left(txtscreen.Text, Len(txtscreen.Text) - 1) 'after removing one number, if there is a dot remove the dot If Strings.Right(txtscreen.Text, 1) = "." Then txtscreen.Text = Strings.Left(txtscreen.Text, Len(txtscreen.Text) - 1) 'if there are no numbers left, write zero If txtscreen.Text = "" Then txtscreen.Text = "0" End Sub Sub actspress(ByVal Operation As OpType) 'if operation pressed then Operation -> actIND save operation type and show operation sign If OperationON Then actIND = Operation operationIND() Exit Sub End If 'if operation was pressed before write solution If actIND > OpType.NA Then solution() End If 'on selecting operation firstnum = number on screen, 'actIND save operation type, show operation sign and save "operrion is pressed" Firstnum = txtscreen.Text actIND = Operation operationIND() OperationON = True End Sub #Region "acts" Private Sub actp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles actp.Click If IsNumeric(txtscreen.Text) = False Then MsgBox("A nuberic value is requiered!") Exit Sub End If actspress(OpType.Plus) End Sub Private Sub actm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles actm.Click If IsNumeric(txtscreen.Text) = False Then MsgBox("A nuberic value is requiered!") Exit Sub End If actspress(OpType.Minus) End Sub Private Sub actX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles actX.Click

  16 

Page 17: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

If IsNumeric(txtscreen.Text) = False Then MsgBox("A nuberic value is requiered!") Exit Sub End If actspress(OpType.Multi) End Sub Private Sub actd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles actd.Click If IsNumeric(txtscreen.Text) = False Then MsgBox("A nuberic value is requiered!") Exit Sub End If actspress(OpType.Div) End Sub Private Sub acts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles acts.Click If IsNumeric(txtscreen.Text) = False Then MsgBox("A nuberic value is requiered!") Exit Sub End If actspress(OpType.Sqr) End Sub Private Sub actR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles actR.Click If IsNumeric(txtscreen.Text) = False Then MsgBox("A nuberic value is requiered!") Exit Sub End If actspress(OpType.Root) End Sub #End Region Private Sub eql_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles eql.Click 'on pressing eql button write solution and clear the operation sign solution() opIND.Image = My.Resources.none End Sub Private Sub solution() Select Case actIND 'ex' if operation = plus Case Is = OpType.Plus 'write on screen sum(or other operation) of both 1st number 'int -> first number, ' and as a double parse the 2nd number (on screen) txtscreen.Text = Firstnum + Double.Parse(txtscreen.Text) Case Is = OpType.Minus txtscreen.Text = Firstnum - Double.Parse(txtscreen.Text) Case Is = OpType.Multi txtscreen.Text = Firstnum * Double.Parse(txtscreen.Text) Case Is = OpType.Div 'if 1nd number / 0(2nd number) write error and exit the sub If txtscreen.Text = 0 Then MsgBox("Cannot divide by zero!")

  17 

Page 18: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

Exit Sub End If txtscreen.Text = Firstnum / Double.Parse(txtscreen.Text) Case Is = OpType.Sqr txtscreen.Text = Math.Pow(Firstnum, Double.Parse(txtscreen.Text)) Case Is = OpType.Root txtscreen.Text = Math.Pow(Firstnum, 1 / Double.Parse(txtscreen.Text)) End Select 'optype = NA actIND = OpType.NA 'round! txtscreen.Text = Math.Round(Double.Parse(txtscreen.Text), 9 - InStr(txtscreen.Text, "."), MidpointRounding.AwayFromZero) 'check overflow! If InStr(txtscreen.Text, ".") > 0 Then If Len(txtscreen.Text) > 9 Then MsgBox("overflow error") txtscreen.Text = 0 End If Else If Len(txtscreen.Text) > 8 Then MsgBox("overflow error") txtscreen.Text = 0 End If End If End Sub Private Sub operationIND() 'show operation sign according to optype Select Case actIND 'ex' if optype = NA then show picture "none"(blank)(other signs for difrent optypes) Case Is = OpType.NA opIND.Image = My.Resources.none Case Is = OpType.Plus opIND.Image = My.Resources.plus Case Is = OpType.Minus opIND.Image = My.Resources.minus Case Is = OpType.Multi opIND.Image = My.Resources.multi Case Is = OpType.Div opIND.Image = My.Resources.div1 Case Is = OpType.Sqr opIND.Image = My.Resources.sqr Case Is = OpType.Root opIND.Image = My.Resources.root End Select End Sub End Class 

 

 

 

  18 

Page 19: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

 

 

OUTPUT OF EXPERIMENT NO:8

 

 

 

 

 

 

 

 

 

 

 

  19 

Page 20: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

          EXPERIMENT NO:8

Design a marksheet of student ,the details of student must be stored into database.Also display the details.

Main.vb 

Public Class Main Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click End End Sub Private Sub StudentRecordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StudentRecordToolStripMenuItem.Click Form1.MdiParent = Me Form1.Show() End Sub Private Sub FeesRecordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FeesRecordToolStripMenuItem.Click ClassName.MdiParent = Me ClassName.Show() End Sub Private Sub TeacherRecordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TeacherRecordToolStripMenuItem.Click Receipt.MdiParent = Me Receipt.Show() End Sub End Class

Form1.vb

Imports System.Data.SqlClient Public Class Form1 Private Sub txtM1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtM1.KeyPress e.KeyChar = CheckNumeric(e.KeyChar, txtM1.Text) End Sub Private Sub txtM2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtM2.KeyPress e.KeyChar = CheckNumeric(e.KeyChar, txtM2.Text) End Sub Private Sub txtM3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtM3.KeyPress e.KeyChar = CheckNumeric(e.KeyChar, txtM3.Text) End Sub Private Sub txtTotal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTotal.KeyPress e.KeyChar = CheckNumeric(e.KeyChar, txtTotal.Text) End Sub

  20 

Page 21: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

Private Sub txtPer_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPer.KeyPress e.KeyChar = CheckNumeric(e.KeyChar, txtPer.Text) End Sub Private Sub txtM1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtM1.TextChanged txtTotal.Text = Val(txtM1.Text) + Val(txtM2.Text) + Val(txtM3.Text) End Sub Private Sub txtM2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtM2.TextChanged txtTotal.Text = Val(txtM1.Text) + Val(txtM2.Text) + Val(txtM3.Text) End Sub Private Sub txtM3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtM3.TextChanged txtTotal.Text = Val(txtM1.Text) + Val(txtM2.Text) + Val(txtM3.Text) End Sub Private Sub txtTotal_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTotal.TextChanged txtPer.Text = Format(Val(txtTotal.Text) / 3, "#0.00") End Sub Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.Enter Then SendKeys.Send("{TAB}") End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Connect() = False Then MsgBox("Sorry! Can't Connect") End End If MaxRollNo() LoadData() FillClass() txtM1.Text = "0" txtM2.Text = "0" txtM3.Text = "0" End Sub Private Sub butExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butExit.Click Me.Dispose() End Sub Private Sub butClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butClear.Click txtRollNo.Text = "" txtName.Text = ""

  21 

Page 22: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

txtM1.Text = "" txtM2.Text = "" txtM3.Text = "" txtTotal.Text = "" txtPer.Text = "" MaxRollNo() LoadData() txtRollNo.Focus() End Sub Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSave.Click If Trim(txtRollNo.Text) = "" Then MsgBox("Enter Roll No.") txtRollNo.Focus() Exit Sub End If If Trim(txtName.Text) = "" Then MsgBox("Enter Name") txtName.Focus() Exit Sub End If Dim s_Sql As String Dim o_Cmd As SqlCommand Try s_Sql = "Insert Into Student (RollNo,Name,CCode,M1,M2,M3,Total,Per) " _ & " Values (@RollNo,@Name,@CCode,@M1,@M2,@M3,@Total,@Per)" o_Cmd = New SqlCommand(s_Sql, o_Con) o_Cmd.Parameters.Add(New SqlParameter("@RollNo", Val(txtRollNo.Text))) o_Cmd.Parameters.Add(New SqlParameter("@Name", txtName.Text)) o_Cmd.Parameters.Add(New SqlParameter("@CCode", Val(cboClass.SelectedValue))) o_Cmd.Parameters.Add(New SqlParameter("@M1", Val(txtM1.Text))) o_Cmd.Parameters.Add(New SqlParameter("@M2", Val(txtM2.Text))) o_Cmd.Parameters.Add(New SqlParameter("@M3", Val(txtM3.Text))) o_Cmd.Parameters.Add(New SqlParameter("@Total", Val(txtTotal.Text))) o_Cmd.Parameters.Add(New SqlParameter("@Per", Val(txtPer.Text))) o_Cmd.ExecuteNonQuery() MsgBox("Data Saved") butClear_Click(sender, e) Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub MaxRollNo() Dim s_Sql As String

  22 

Page 23: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

Dim o_Cmd As SqlCommand Dim o_Reader As SqlDataReader s_Sql = "Select max(RollNo) from Student" o_Cmd = New SqlCommand(s_Sql, o_Con) o_Reader = o_Cmd.ExecuteReader If o_Reader.Read = True Then txtRollNo.Text = Val(o_Reader(0)) + 1 Else txtRollNo.Text = 1 End If o_Cmd.Dispose() o_Reader.Close() End Sub Private Sub LoadData() Dim s_Sql As String Dim o_Cmd As SqlCommand Dim o_Reader As SqlDataReader Dim Lv As ListViewItem ListView1.Items.Clear() s_Sql = "Select S.RollNo,S.Name,C.ClassName,S.M1,S.M2,S.M3,S.Total,S.Per " _ & " from Student S LEFT OUTER JOIN ClassName C " _ & " ON (S.CCode=C.CCode) " _ & " Where S.Name like '" & txtSearch.Text & "%'" o_Cmd = New SqlCommand(s_Sql, o_Con) o_Reader = o_Cmd.ExecuteReader While o_Reader.Read Lv = ListView1.Items.Add("") Lv.Text = o_Reader("RollNo") & "" Lv.SubItems.Add(o_Reader("Name") & "") Lv.SubItems.Add(o_Reader("ClassName") & "") Lv.SubItems.Add(o_Reader("M1") & "") Lv.SubItems.Add(o_Reader("M2") & "") Lv.SubItems.Add(o_Reader("M3") & "") Lv.SubItems.Add(o_Reader("Total") & "") Lv.SubItems.Add(o_Reader("Per") & "") End While o_Reader.Close() End Sub Private Sub FillClass() Dim s_Sql As String Dim o_Dataset As Data.DataSet Dim o_Adapter As SqlDataAdapter s_Sql = "Select ClassName,CCode from ClassName Group By ClassName,CCode" o_Adapter = New SqlDataAdapter(s_Sql, o_Con) o_Dataset = New DataSet o_Adapter.Fill(o_Dataset)

  23 

Page 24: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

cboClass.DataSource = o_Dataset.Tables(0) cboClass.DisplayMember = o_Dataset.Tables(0).Columns(0).ColumnName cboClass.ValueMember = o_Dataset.Tables(0).Columns(1).ColumnName o_Dataset.Dispose() o_Adapter.Dispose() End Sub Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick txtRollNo.Text = ListView1.SelectedItems(0).Text txtName.Text = ListView1.SelectedItems(0).SubItems(1).Text txtM1.Text = ListView1.SelectedItems(0).SubItems(2).Text txtM2.Text = ListView1.SelectedItems(0).SubItems(3).Text txtM3.Text = ListView1.SelectedItems(0).SubItems(4).Text txtTotal.Text = ListView1.SelectedItems(0).SubItems(5).Text txtPer.Text = ListView1.SelectedItems(0).SubItems(6).Text End Sub Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged End Sub Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged LoadData() End Sub End Class Module 1 

Imports System.Data.SqlClient Module Module1 Public o_Con As SqlConnection Public Function Connect() As Boolean Try o_Con = New SqlConnection o_Con.ConnectionString = "SERVER=.\SQLExpress; Database=training01; Trusted_Connection=true" 'o_Con.ConnectionString = "SERVER=.\SQLExpress; Database=training01; User=Sa; Password=123" o_Con.Open() Connect = True Catch ex As Exception MsgBox(ex.Message) Connect = False End Try End Function Public Function CheckNumeric(ByVal KeyChar As String, ByVal Text As String) As String If Asc(KeyChar) = 8 Then Return KeyChar End If If InStr(Text, ".") <> 0 And KeyChar = "." Then Return KeyChar

  24 

Page 25: OUTPUT OF EXPERIMENT NO:1 › 2015 › 02 › 7th-sem-lab-vbne… · 7/2/2015  · EXPERIMENT NO:1 . WAP to find the Average, Total Grade of student using if else statements (In Console)

End If If (KeyChar >= "0" And KeyChar <= "9") Or KeyChar = "." Then Return KeyChar Else Return "" End If End Function End Module  

 

 

 

 

 

 

 

 

 

 

  25