Sie sind auf Seite 1von 36

Ques.

1-

Convert degree celcius to ferrenheit and vise versa.

Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.TextBox2 = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.AccessibleRole = System.Windows.Forms.AccessibleRole.None Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.Color.Magenta Me.Label1.Location = New System.Drawing.Point(32, 48) Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing.Size(120, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Enter Temperature" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(168, 48) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(216, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.BackColor = System.Drawing.Color.Pink Me.Button1.ForeColor = System.Drawing.Color.Magenta Me.Button1.Location = New System.Drawing.Point(96, 160) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(248, 40) Me.Button1.TabIndex = 2 Me.Button1.Text = "Convert Celcius to Ferrenheit" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(168, 104) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(216, 20) Me.TextBox2.TabIndex = 3 Me.TextBox2.Text = "" ' 'Label2 ' Me.Label2.AccessibleRole = System.Windows.Forms.AccessibleRole.None Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.ForeColor = System.Drawing.Color.Magenta Me.Label2.Location = New System.Drawing.Point(32, 104) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(120, 24) Me.Label2.TabIndex = 4 Me.Label2.Text = "Results" ' 'Button2 ' Me.Button2.BackColor = System.Drawing.Color.Pink Me.Button2.ForeColor = System.Drawing.Color.Magenta Me.Button2.Location = New System.Drawing.Point(96, 224) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(248, 40) Me.Button2.TabIndex = 5 Me.Button2.Text = "Convert Ferrenheit to Celcius" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.LightPink Me.ClientSize = New System.Drawing.Size(432, 310) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Button1)

Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim c, f As Double c = TextBox1.Text f = (1.8 * c) + 32 TextBox2.Text = f End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim f, c As Double f = TextBox1.Text c = (f - 32) / 1.8 TextBox2.Text = c End Sub End Class

OUTPUT:

Ques. 2not.

Check wheather the given string is Palindrome or

Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.Color.Navy Me.Label1.Location = New System.Drawing.Point(24, 72) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(104, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Enter a string" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(144, 72) Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(232, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.BackColor = System.Drawing.Color.Navy Me.Button1.ForeColor = System.Drawing.Color.Lavender Me.Button1.Location = New System.Drawing.Point(136, 168) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(184, 48) Me.Button1.TabIndex = 2 Me.Button1.Text = "Check Palindrome" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.Lavender Me.ClientSize = New System.Drawing.Size(432, 270) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str1, str2 As String str1 = TextBox1.Text str2 = StrReverse(str1) If str2 = str1 Then MsgBox("The string is Palindrome") Else MsgBox("The string is not Palindrome") End If End Sub End Class

OUTPUT:

Ques. 3- Check for the palindrome using Procedure.


Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Button1 ' Me.Button1.BackColor = System.Drawing.Color.Magenta Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.ForeColor = System.Drawing.Color.Pink Me.Button1.Location = New System.Drawing.Point(88, 152) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(176, 48) Me.Button1.TabIndex = 0 Me.Button1.Text = "Check For Palindrome" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(144, 48) Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(192, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.Color.Magenta Me.Label1.Location = New System.Drawing.Point(16, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(120, 24) Me.Label1.TabIndex = 2 Me.Label1.Text = "Enter a String" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.Pink Me.ClientSize = New System.Drawing.Size(352, 286) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim arr1(10), arr2(10) As String Dim i, j, len As Integer arr1(i) = TextBox1.Text len = arr1.Length For i = 0 To len arr1(i) = TextBox1.Text.Substring(i, 1) Next For i = len To 0 Step -1 For j = 0 To len arr2(j) = arr1(i) Next Next If arr2 Is arr1 Then MsgBox("The string is palindrome") Else MsgBox("The string is not palindrome") End If End Sub End Class

OUTPUT: Same as above

Ques. 4-

Check for fine.

Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents TextBox3 As System.Windows.Forms.TextBox Friend WithEvents TextBox4 As System.Windows.Forms.TextBox Friend WithEvents TextBox5 As System.Windows.Forms.TextBox Friend WithEvents TextBox6 As System.Windows.Forms.TextBox Friend WithEvents TextBox7 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.TextBox3 = New System.Windows.Forms.TextBox

Me.TextBox4 = New System.Windows.Forms.TextBox Me.TextBox5 = New System.Windows.Forms.TextBox Me.TextBox6 = New System.Windows.Forms.TextBox Me.TextBox7 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.Color.Magenta Me.Label1.Location = New System.Drawing.Point(24, 40) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(144, 32) Me.Label1.TabIndex = 0 Me.Label1.Text = "Member Name" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.ForeColor = System.Drawing.Color.Magenta Me.Label2.Location = New System.Drawing.Point(24, 96) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(144, 32) Me.Label2.TabIndex = 1 Me.Label2.Text = "Address" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.ForeColor = System.Drawing.Color.Magenta Me.Label3.Location = New System.Drawing.Point(24, 152) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(144, 32) Me.Label3.TabIndex = 2 Me.Label3.Text = "Phone Number" ' 'Label4 ' Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.ForeColor = System.Drawing.Color.Magenta Me.Label4.Location = New System.Drawing.Point(336, 40) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(136, 32) Me.Label4.TabIndex = 3 Me.Label4.Text = "Book Name" ' 'Label5 ' Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.ForeColor = System.Drawing.Color.Magenta Me.Label5.Location = New System.Drawing.Point(336, 96) Me.Label5.Name = "Label5"

Me.Label5.Size = New System.Drawing.Size(136, 32) Me.Label5.TabIndex = 4 Me.Label5.Text = "Date Of Issue" ' 'Label6 ' Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label6.ForeColor = System.Drawing.Color.Magenta Me.Label6.Location = New System.Drawing.Point(336, 152) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(136, 32) Me.Label6.TabIndex = 5 Me.Label6.Text = "Date Of Return" ' 'Label7 ' Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label7.ForeColor = System.Drawing.Color.Magenta Me.Label7.Location = New System.Drawing.Point(216, 216) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(112, 32) Me.Label7.TabIndex = 6 Me.Label7.Text = "Fine Ammount" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(176, 32) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(144, 20) Me.TextBox1.TabIndex = 7 Me.TextBox1.Text = "" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(176, 96) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(144, 20) Me.TextBox2.TabIndex = 8 Me.TextBox2.Text = "" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(176, 152) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size(144, 20) Me.TextBox3.TabIndex = 9 Me.TextBox3.Text = "" ' 'TextBox4 ' Me.TextBox4.Location = New System.Drawing.Point(488, 40) Me.TextBox4.Name = "TextBox4" Me.TextBox4.Size = New System.Drawing.Size(144, 20) Me.TextBox4.TabIndex = 10 Me.TextBox4.Text = "" ' 'TextBox5 ' Me.TextBox5.Location = New System.Drawing.Point(488, 96)

Me.TextBox5.Name = "TextBox5" Me.TextBox5.Size = New System.Drawing.Size(144, 20) Me.TextBox5.TabIndex = 11 Me.TextBox5.Text = "" ' 'TextBox6 ' Me.TextBox6.Location = New System.Drawing.Point(488, 152) Me.TextBox6.Name = "TextBox6" Me.TextBox6.Size = New System.Drawing.Size(144, 20) Me.TextBox6.TabIndex = 12 Me.TextBox6.Text = "" ' 'TextBox7 ' Me.TextBox7.Location = New System.Drawing.Point(352, 216) Me.TextBox7.Name = "TextBox7" Me.TextBox7.Size = New System.Drawing.Size(144, 20) Me.TextBox7.TabIndex = 13 Me.TextBox7.Text = "" Me.TextBox7.Visible = False ' 'Button1 ' Me.Button1.BackColor = System.Drawing.Color.Magenta Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.ForeColor = System.Drawing.Color.LavenderBlush Me.Button1.Location = New System.Drawing.Point(168, 312) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(368, 56) Me.Button1.TabIndex = 14 Me.Button1.Text = "Check For Fine" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.LavenderBlush Me.ClientSize = New System.Drawing.Size(672, 406) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox7) Me.Controls.Add(Me.TextBox6) Me.Controls.Add(Me.TextBox5) Me.Controls.Add(Me.TextBox4) Me.Controls.Add(Me.TextBox3) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dt1, dt2 As Date Dim diff_date, fine As Integer Dim temp As Object dt1 = TextBox6.Text dt2 = Date.Today diff_date = DateDiff("d", dt1, dt2) If diff_date = 0 Then MsgBox("No fine") ElseIf diff_date < 0 Then MsgBox("No fine") Else fine = diff_date * 5 TextBox7.Text = fine TextBox7.Visible = True End If temp = TextBox7.Text If temp = Nothing Then temp = "Nil" TextBox7.Text = temp End If TextBox7.Visible = True End Sub End Class

OUTPUT:

Ques. 5- Find the length of a given string entered in a text box and show it in another text box.
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.MainMenu1 = New System.Windows.Forms.MainMenu(Me.components) Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.TextBox2 = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(24, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(93, 24) Me.Label1.TabIndex = 0

Me.Label1.Text = "Enter the text" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(136, 48) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(117, 20) Me.TextBox1.TabIndex = 1 ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(80, 136) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(116, 38) Me.Button1.TabIndex = 2 Me.Button1.Text = "length of string" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(136, 201) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(117, 20) Me.TextBox2.TabIndex = 3 ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(24, 201) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(46, 18) Me.Label2.TabIndex = 4 Me.Label2.Text = "Result" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(4, 13) Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer)) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Font = New System.Drawing.Font("Monotype Corsiva", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Menu = Me.MainMenu1 Me.Name = "Form1" Me.Text = "DPS" Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim a As Integer End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str As String Dim l As Integer str = TextBox1.Text l = Len(str) TextBox2.Text = l End Sub End Class

OUTPUT:

Ques.6- Take user input in structure variable and then display them through msgbox()
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents TextBox3 As System.Windows.Forms.TextBox Friend WithEvents TextBox4 As System.Windows.Forms.TextBox Friend WithEvents TextBox5 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label2 = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.Label4 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.TextBox2 = New System.Windows.Forms.TextBox() Me.TextBox3 = New System.Windows.Forms.TextBox() Me.TextBox4 = New System.Windows.Forms.TextBox() Me.TextBox5 = New System.Windows.Forms.TextBox() Me.Button1 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.Label1 = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'Label2

' Me.Label2.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(8, 216) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(88, 16) Me.Label2.TabIndex = 2 Me.Label2.Text = "Salary" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(8, 168) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(88, 16) Me.Label3.TabIndex = 3 Me.Label3.Text = "Designation" ' 'Label4 ' Me.Label4.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.Location = New System.Drawing.Point(8, 120) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(88, 16) Me.Label4.TabIndex = 4 Me.Label4.Text = "Department" ' 'Label5 ' Me.Label5.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.Location = New System.Drawing.Point(8, 72) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(88, 16) Me.Label5.TabIndex = 5 Me.Label5.Text = "Name" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(136, 112) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(104, 20) Me.TextBox2.TabIndex = 6 Me.TextBox2.Text = "" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(136, 160) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size(104, 20) Me.TextBox3.TabIndex = 7 Me.TextBox3.Text = "" '

'TextBox4 ' Me.TextBox4.Location = New System.Drawing.Point(136, 208) Me.TextBox4.Name = "TextBox4" Me.TextBox4.Size = New System.Drawing.Size(104, 20) Me.TextBox4.TabIndex = 8 Me.TextBox4.Text = "" ' 'TextBox5 ' Me.TextBox5.Location = New System.Drawing.Point(136, 64) Me.TextBox5.Name = "TextBox5" Me.TextBox5.Size = New System.Drawing.Size(104, 20) Me.TextBox5.TabIndex = 9 Me.TextBox5.Text = "" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(80, 248) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(128, 24) Me.Button1.TabIndex = 10 Me.Button1.Text = "SUBMIT" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(136, 24) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(104, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Label1 ' Me.Label1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte)) Me.Label1.Font = New System.Drawing.Font("Monotype Corsiva", 12.0!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.Color.Blue Me.Label1.Location = New System.Drawing.Point(8, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(88, 16) Me.Label1.TabIndex = 0 Me.Label1.Text = "ENo" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte)) Me.ClientSize = New System.Drawing.Size(292, 301) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TextBox5, Me.TextBox4, Me.TextBox3, Me.TextBox2, Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.TextBox1, Me.Label1}) Me.ForeColor = System.Drawing.Color.Blue Me.Name = "Form1" Me.Text = "Form1"

Me.ResumeLayout(False) End Sub #End Region Structure employee Dim eno As Integer Dim name As String Dim department As String Dim designation As String Dim salary As Integer End Structure Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim emp1 As employee emp1.eno = TextBox1.Text emp1.name = TextBox5.Text emp1.department = TextBox2.Text emp1.designation = TextBox3.Text emp1.salary = TextBox4.Text MsgBox(emp1.eno & emp1.name & emp1.department & emp1.designation & emp1.salary) End Sub End Class

OUTPUT:

Ques.7- Show the Usage timers.


Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents Label9 As System.Windows.Forms.Label Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton Friend WithEvents Label10 As System.Windows.Forms.Label Friend WithEvents Timer2 As System.Windows.Forms.Timer Friend WithEvents Timer3 As System.Windows.Forms.Timer Friend WithEvents Timer4 As System.Windows.Forms.Timer Friend WithEvents Timer1 As System.Windows.Forms.Timer <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.RadioButton4 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton

Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.Label9 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.Timer2 = New System.Windows.Forms.Timer(Me.components) Me.Timer3 = New System.Windows.Forms.Timer(Me.components) Me.Timer4 = New System.Windows.Forms.Timer(Me.components) Me.Label10 = New System.Windows.Forms.Label Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 17.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(24, 56) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(118, 29) Me.Label1.TabIndex = 0 Me.Label1.Text = "Question-" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.RadioButton4) Me.GroupBox1.Controls.Add(Me.RadioButton3) Me.GroupBox1.Controls.Add(Me.RadioButton2) Me.GroupBox1.Controls.Add(Me.RadioButton1) Me.GroupBox1.Controls.Add(Me.Label9) Me.GroupBox1.Controls.Add(Me.Label8) Me.GroupBox1.Controls.Add(Me.Label7) Me.GroupBox1.Controls.Add(Me.Label6) Me.GroupBox1.Controls.Add(Me.Label5) Me.GroupBox1.Controls.Add(Me.Label4) Me.GroupBox1.Controls.Add(Me.Label3) Me.GroupBox1.Controls.Add(Me.Label2) Me.GroupBox1.Location = New System.Drawing.Point(24, 120) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(392, 136) Me.GroupBox1.TabIndex = 2 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Options" ' 'RadioButton4 ' Me.RadioButton4.Location = New System.Drawing.Point(216, 88) Me.RadioButton4.Name = "RadioButton4" Me.RadioButton4.Size = New System.Drawing.Size(16, 24) Me.RadioButton4.TabIndex = 11 ' 'RadioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point(216, 32) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size(16, 24) Me.RadioButton3.TabIndex = 10

' 'RadioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point(37, 88) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size(16, 24) Me.RadioButton2.TabIndex = 9 ' 'RadioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point(37, 32) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size(16, 24) Me.RadioButton1.TabIndex = 8 Me.RadioButton1.Visible = False ' 'Label9 ' Me.Label9.AutoSize = True Me.Label9.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer)) Me.Label9.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label9.Location = New System.Drawing.Point(238, 88) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing.Size(62, 25) Me.Label9.TabIndex = 7 Me.Label9.Text = "Cycle" Me.Label9.Visible = False ' 'Label8 ' Me.Label8.AutoSize = True Me.Label8.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer)) Me.Label8.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label8.Location = New System.Drawing.Point(238, 32) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(107, 25) Me.Label8.TabIndex = 6 Me.Label8.Text = "Motorcycle" Me.Label8.Visible = False ' 'Label7 ' Me.Label7.AutoSize = True Me.Label7.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer)) Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label7.Location = New System.Drawing.Point(59, 87) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(69, 25) Me.Label7.TabIndex = 5 Me.Label7.Text = "scooty" Me.Label7.Visible = False

' 'Label6 ' Me.Label6.AutoSize = True Me.Label6.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer)) Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label6.Location = New System.Drawing.Point(59, 32) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(80, 25) Me.Label6.TabIndex = 4 Me.Label6.Text = "Scooter" Me.Label6.Visible = False ' 'Label5 ' Me.Label5.AutoSize = True Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 13.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.Location = New System.Drawing.Point(192, 88) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(23, 22) Me.Label5.TabIndex = 3 Me.Label5.Text = "D" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 13.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.Location = New System.Drawing.Point(192, 32) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(22, 22) Me.Label4.TabIndex = 2 Me.Label4.Text = "B" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 13.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(16, 88) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(23, 22) Me.Label3.TabIndex = 1 Me.Label3.Text = "C" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 13.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(16, 32) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(22, 22) Me.Label2.TabIndex = 0

Me.Label2.Text = "A" ' 'Timer1 ' Me.Timer1.Enabled = True Me.Timer1.Interval = 1100 ' 'Timer2 ' Me.Timer2.Enabled = True Me.Timer2.Interval = 2100 ' 'Timer3 ' Me.Timer3.Enabled = True Me.Timer3.Interval = 3100 ' 'Timer4 ' Me.Timer4.Enabled = True Me.Timer4.Interval = 4100 ' 'Label10 ' Me.Label10.AutoSize = True Me.Label10.Font = New System.Drawing.Font("Microsoft Sans Serif", 17.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label10.Location = New System.Drawing.Point(184, 56) Me.Label10.Name = "Label10" Me.Label10.Size = New System.Drawing.Size(232, 29) Me.Label10.TabIndex = 3 Me.Label10.Text = "Pick the odd one out" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer)) Me.ClientSize = New System.Drawing.Size(554, 349) Me.Controls.Add(Me.Label10) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Start() Label6.Visible = True RadioButton1.Visible = True Timer1.Stop() End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Timer2.Start() Label8.Visible = True Timer2.Stop() End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick Timer3.Start() Label7.Visible = True Timer3.Stop() End Sub Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick Timer4.Start() Label9.Visible = True Timer4.Stop() End Sub End Class

OUTPUT:

Ques.8- Make a dialog box and show its usage.


Coding for form1:
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(56, 112) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(192, 48) Me.Button1.TabIndex = 0 Me.Button1.Text = "Show Dialog" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1}) Me.Name = "Form1" Me.Text = "Form1"

Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm2 As New Form2() frm2.Show() End Sub End Class

Coding for form2:


Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.Button1.Location = New System.Drawing.Point(24, 128) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(112, 40) Me.Button1.TabIndex = 0 Me.Button1.Text = "Ok" ' 'Button2 ' Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(160, 128) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(112, 40) Me.Button2.TabIndex = 1 Me.Button2.Text = "Cancel" ' 'Form2 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1}) Me.Name = "Form2" Me.Text = "Form2" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("The OK Button") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox("The Cancel Button") End Sub End Class

OUTPUT:

Ques.9- Give an example to use classes in vb.net and calling its member functions. Coding for the class i.e. taxclass :
Public Class taxclass Overloads Function taxamount(ByVal decprice As Decimal, ByVal taxrate As Single) As String taxamount = CStr(decprice * taxrate) End Function Overloads Function taxamount(ByVal strprice As String, ByVal taxrate As Single) As String taxamount = CStr(CDec(strprice) * taxrate) End Function End Class

Coding for form1:

Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Book Antiqua", 15.75!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.ForeColor = System.Drawing.Color.BlueViolet Me.Button1.Location = New System.Drawing.Point(64, 80) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(184, 40) Me.Button1.TabIndex = 0 Me.Button1.Text = "Show Tax"

' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte)) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1}) Me.ForeColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte)) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click showtax() End Sub Sub showtax() Const taxrate As Single = 0.08 '8% tax rate' Dim strprice As String = "64.00" Dim decprice As Decimal = 64 Dim aclass As New taxclass() MsgBox(aclass.taxamount(strprice, taxrate)) MsgBox(aclass.taxamount(decprice, taxrate)) End Sub End Class

OUTPUT:

Ques.10- Swap two values using a function and passing the values by reference.
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel Friend WithEvents LinkLabel2 As System.Windows.Forms.LinkLabel Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.LinkLabel1 = New System.Windows.Forms.LinkLabel Me.LinkLabel2 = New System.Windows.Forms.LinkLabel Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'LinkLabel1 ' Me.LinkLabel1.AutoSize = True Me.LinkLabel1.Font = New System.Drawing.Font("Monotype Corsiva", 16.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LinkLabel1.Location = New System.Drawing.Point(48, 48) Me.LinkLabel1.Name = "LinkLabel1" Me.LinkLabel1.Size = New System.Drawing.Size(79, 26) Me.LinkLabel1.TabIndex = 0 Me.LinkLabel1.TabStop = True Me.LinkLabel1.Text = "Value 1" 'LinkLabel2 Me.LinkLabel2.AutoSize = True Me.LinkLabel2.Font = New System.Drawing.Font("Monotype Corsiva", 16.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.LinkLabel2.Location = New System.Drawing.Point(48, 112) Me.LinkLabel2.Name = "LinkLabel2" Me.LinkLabel2.Size = New System.Drawing.Size(79, 26) Me.LinkLabel2.TabIndex = 1 Me.LinkLabel2.TabStop = True Me.LinkLabel2.Text = "Value 2" 'TextBox1 Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TextBox1.Location = New System.Drawing.Point(208, 40) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(100, 29) Me.TextBox1.TabIndex = 2 'TextBox2 Me.TextBox2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TextBox2.Location = New System.Drawing.Point(208, 104) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(100, 29) Me.TextBox2.TabIndex = 3 'Button1 Me.Button1.Font = New System.Drawing.Font("Monotype Corsiva", 18.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.ForeColor = System.Drawing.Color.Blue Me.Button1.Location = New System.Drawing.Point(144, 176) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(134, 50) Me.Button1.TabIndex = 4 Me.Button1.Text = "SWAP" 'Form1 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(435, 273) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.LinkLabel2) Me.Controls.Add(Me.LinkLabel1) Me.ForeColor = System.Drawing.Color.FromArgb(CType(CType(128, Byte), Integer), CType(CType(128, Byte), Integer), CType(CType(255, Byte), Integer)) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b As Integer Dim res As Boolean a = CInt(TextBox1.Text) b = CInt(TextBox2.Text) res = swap(a, b) If res Then MsgBox("Swap successfully done") End If TextBox1.Text = CStr(a) TextBox2.Text = CStr(b) End Sub

Function swap(ByRef x As Integer, ByRef y As Integer) As Boolean Dim t As Integer t = x x = y y = t MsgBox("Value 1 after swap:" & x & Chr(13) & "Value after swap:" & y) swap = True End Function End Class

OUTPUT:

Das könnte Ihnen auch gefallen