Anda di halaman 1dari 27

Q. 1Design an application for addition , subtraction , multiplication and division of two number. 1.

Code for the subtract command (Command2). The code will be as follows: Private Sub Command2_Click() a = Val(Text1.Text) b = Val(Text2.Text) r=a-b Text3.Text = r End Sub Code for the multiply command (Command3). The code will be as follows:

Private Sub Command3_Click() a = Val(Text1.Text) b = Val(Text2.Text) r=a*b Text3.Text = r End Sub Code for the divide command (Command4). The coding will be as follows:

Private Sub Command4_Click() a = Val(Text1.Text) b = Val(Text2.Text) r=a/b Text3.Text = r End Sub Start the coding for the add command (Command1). The code will be as follows:

Private Sub Command1_Click() a = Val(Text1.Text) b = Val(Text2.Text)

r=a+b Text3.Text = r End Sub

Out put

02 Design An Application For display factorial of a number , input by the user . Private sub command1 _ click ( ) Dim a , I, f As Double i=1 f=1 a=val(text1.text) while i<=a f=f* i i=i+1 wend text2.text=val( ) end sub private sub command 2_ click ( ) text1.text= End sub

OUT PUT

Q.3 design an application for displaying Fibonacci series


Private Sub Command1_Click() Dim x, g, n, i, sum As Integer n = Val(Text1.Text) x=0 y=1 Print x Print y For i = 3 To n sum = x + y Print sum x=y y = sum y = sum Next i End Sub

Out put

Q.4 Design An Application For Displaying For A Calculator Dim Op1, Op2 As Double Dim Opr As String Private Sub Command1_Click() Text1.Text = Text1.Text + Command1.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command2_Click() Text1.Text = Text1.Text + Command2.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command3_Click() Text1.Text = Text1.Text + Command3.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command4_Click() Text1.Text = Text1.Text + Command4.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub

Private Sub Command5_Click() Text1.Text = Text1.Text + Command5.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command6_Click() Text1.Text = Text1.Text + Command6.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command7_Click() Text1.Text = Text1.Text + Command7.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command8_Click() Text1.Text = Text1.Text + Command8.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command9_Click() Text1.Text = Text1.Text + Command9.Caption If cleardisplay Then

Text1.Text = "" cleardisplay = False End If End Sub Private Sub Command10_Click() Text1.Text = Text1.Text + Command10.Caption If cleardisplay Then Text1.Text = "" cleardisplay = False End If End Sub Private Sub CommandDot_Click() If InStr(Text1.Text, ".") Then Exit Sub Else Text1.Text = Text1.Text + "." End If End Sub Private Sub Commandcls_Click() Text1.Text = "" End Sub Private Sub CommandPlus_Click() Op1 = Val(Text1.Text) Opr = "+" Text1.Text = "" End Sub Private Sub CommandMinus_Click() Op1 = Val(Text1.Text) Opr = "-" Text1.Text = "" End Sub Private Sub CommandMul_Click() Op1 = Val(Text1.Text) Opr = "*"

Text1.Text = "" End Sub Private Sub CommandDiv_Click() Op1 = Val(Text1.Text) Opr = "/" Text1.Text = "" End Sub Private Sub CommandEqu_Click() Op2 = Val(Text1.Text) Select Case Opr Case "+": Text1.Text = Op1 + Op2 Case "*": Text1.Text = Op1 * Op2 Case "-": Text1.Text = Op1 - Op2 Case "/": Text1.Text = Op1 / Op2 End Select End Sub Private Sub Commandexit_Click() End End Sub Private Sub Form_Load() Text1.Text = "" End Sub

OUT PUT

Q. 5 Design an application for displaying even numbers from 1 to 50. dim a(50) as integer dim i as integer dim n as integer private sub command_click() for i 1 to 50 Next i a(i) = inputbox ("enter any no.""no.""0") Next i for i = 1 to 50 print a(i) n=n/i if n mod 2 = 0 then Next i end if msgbox "even numbe"&even end if

OUT PUT

Q.6 Design An Application For Counting Even And Odd Numbers.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Odd_and_even_numbers { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { listBox1.Items.Clear(); int limit = Convert.ToInt32(textBox1.Text); for (int i = 1; i <= limit; i = i + 2) { listBox1.Items.Add(i).ToString(); } } catch (Exception) { MessageBox.Show("Invalid Limit"); } } private void button2_Click(object sender, EventArgs e) {

try { listBox1.Items.Clear(); int limit = Convert.ToInt32(textBox1.Text); for (int i = 2; i <= limit; i = i + 2) { listBox1.Items.Add(i).ToString(); } } catch (Exception) { MessageBox.Show("Invalid Limit"); } } } }

OUT PUT

Q. 8Design an application for converting fahrenheit to Celsius and vice versa Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols <WebService(Namespace:="http://tempuri.org/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Public Class Service Inherits System.Web.Services.WebService <WebMethod()> _ Public Function HelloWorld() As String Return "Hello World" End Function <WebMethod()> Public Function FahrenheitToCelsius(ByVal Fahrenheit As String) As String Dim fahr fahr = Trim(Replace(Fahrenheit, ",", ".")) If fahr = "" Or IsNumeric(fahr) = False Then Return "Error" Return ((((fahr) - 32) / 9) * 5) End Function <WebMethod()> Public Function CelsiusToFahrenheit(ByVal Celsius As String) As String Dim cel cel = Trim(Replace(Celsius, ",", ".")) If cel = "" Or IsNumeric(cel) = False Then Return "Error"

form target="_blank" action="Service.asmx/FahrenheitToCelsius" method="POST"> <table> <tr> <td>Fahrenheit to Celsius:</td> <td><input class="frmInput" type="text" size="30" name="Fahrenheit"></td> </tr> <tr> <td></td> <td align="right"> <input type="submit" value="Submit" class="button"></td> </tr> </table> </form> <form target="_blank" action="Service.asmx/CelsiusToFahrenheit" method="POST"> <table> <tr> <td>Celsius to Fahrenheit:</td> <td><input class="frmInput" type="text" size="30" name="Celsius"></td> </tr> <tr> <td></td>

<td align="right"> <input type="submit" value="Submit" class="button"></td> </tr> </table> </form>

OUT PUT

Q.9 Design an application for fill registration form and display

Private Shared kLibraryKey As String = "3F76246B3B0E194506CBC8F512D70B9D0EF8242CEFA92E03237D7152AF 70DBD428ED559FBB90" ' The register state of the application which is computed when the form is loaded Private registered As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim Proc As Process = Process.GetCurrentProcess() ' This call will display the trial dialogs if needed Dim ret = InitTrial(kLibraryKey, Proc.MainWindowHandle) ' 0 return code means that the application is registered using a valid code, otherwise is in trial If ret = 0 Then registered = True End If Catch ex As Exception MessageBox.Show(ex.ToString()) Process.GetCurrentProcess().Kill() End Try End Sub Private Sub DoRegister() Try Dim Proc As Process = Process.GetCurrentProcess()

Dim ret = DisplayRegistration(kLibraryKey, Proc.MainWindowHandle) ' 0 return code means that the application was already registered or it ' has just been registered, otherwise is in trial If ret = 0 Then registered = True End If Catch ex As Exception MessageBox.Show(ex.ToString()) Close() End Try End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click Dim dlg As AboutBox1 = New AboutBox1 ' Set the about box member to the registered state computed when the application loaded dlg.registered = Me.registered ' Display the About box dlg.Show() End Sub Private Sub RegisterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegisterToolStripMenuItem.Click If registered Then MessageBox.Show("The application is already registered.", "Registered", MessageBoxButtons.OK, MessageBoxIcon.Information) Else DoRegister()

End If End Sub Into the AboutBox1.vb source file add the following code snippets: ... Public registered As Boolean Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ... If Me.registered Then Me.TextBoxDescription.Text = "registered - thank you" Else Me.TextBoxDescription.Text = "trial" End If End Sub

OUT PUT

INDEX S.NO. 1 PROGRAMS Design an application for addition , subtraction , multiplication and division of two numbers.

Design an application for display factorial of a number, input by the user.

3 4 5 6 7

Design an application for displaying Fibonacci series. Design an application for a calculator. Design an application for despising even numbers from 1 to 50. Design an application for counting even odd numbers. Design an application for checking user id and password in maximum three attempts.

Design an application for converting Fahrenheit to Celsius and vice versa .

9 10

Design an application for fill registration from display Design an application that displays shapes as per the commands selected on its menu . the menu displayed on the application should be as .

PRACTICAL FILE ON VISUAL BASIC

SUBMITTED TO :ASST. PROF NEHA BHARDWAJ ASST. PROF. GYANU GUPTA

SUBMITTED BY :KAVITA
2ND YEAR 3RD SEM (CIVIL )

Anda mungkin juga menyukai