0% found this document useful (0 votes)
54 views3 pages

Visaula Programs

Visaula Programs

Uploaded by

Krishna Bashyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Visaula Programs

Visaula Programs

Uploaded by

Krishna Bashyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Write a configuration code for connecting WAP to add 2 numbers using call by Write a graphic program to draw a

a database with VB application. value and call by reference. ellipse and rectangle.

Imports [Link] Module Program Imports [Link]


Sub Main() Imports [Link]
Public Class DatabaseConnection Dim num1 As Integer = 10
Public Class GraphicsExample
Dim num2 As Integer = 20
Private connectionString As String = "Data Inherits Form
Source=ServerName; Initial Catalog= Dim resultByValue As Integer =
DatabaseName; User ID=Username; AddByValue(num1, num2) Public Sub New()
Password=Password;" [Link] = "Graphics Example"
[Link]("Result using call by
Private connection As SqlConnection value: " & resultByValue) [Link] = New Size(400, 400)
End Sub
Public Sub New() Dim resultByReference As Integer
Protected Overrides Sub OnPaint(ByVal e
connection = New SqlConnection AddByReference(num1, num2, As PaintEventArgs)
(connectionString) resultByReference)
[Link](e)
[Link]("Result using call by
End Sub Dim g As Graphics = [Link]
reference: " & resultByReference)
Public Function OpenConnection() As Dim pen As New Pen([Link], 2)
[Link]()
Boolean Dim brush As New SolidBrush([Link])
End Sub [Link](pen, New Rectangle(50, 50,
Try
Function AddByValue(ByVal num1 As 100, 80))
[Link]() Integer, ByVal num2 As Integer) As Integer [Link](brush, New Rectangle(200, 50,
100, 80))
[Link]("Connection opened Return num1 + num2
successfully") [Link](pen, New Rectangle(50,
End Function 200, 100, 80))
Return True
Sub AddByReference(ByVal num1 As [Link](brush, New Rectangle(200,
Catch ex As Exception Integer, ByVal num2 As Integer, ByRef 200, 100, 80))
result As Integer) [Link]()
[Link]("Error opening [Link]()
connection: " & [Link]) result = num1 + num2
End Sub [Link]()
Return False End Module End Sub
Public Shared Sub Main()
End Try
[Link](New GraphicsExample())
End Function Write a program for reading text file and
End Sub
displaying on system.
Public Sub CloseConnection() End Class
Imports [Link]
If [Link] = [Link] Module Program
Then Write a program to find the sum of the
Sub Main()
even numbers up to 100 using for loop.
[Link]() Dim filePath As String = "C:\path\[Link]"
Module Program
[Link]("Connection closed") If [Link](filePath) Then Sub Main()
Dim lines() As String = Dim sum As Integer = 0
End If
[Link](filePath) For i As Integer = 1 To 100
End Sub For Each line As String In lines If i Mod 2 = 0 Then
End Class [Link](line) sum += i
Next End If
Else Next
[Link]("File not found.") [Link]("Sum of even numbers
End If up to 100: " & sum)

[Link]() [Link]()

End Sub End Sub

End Module End Module


Write a program to input few numbers Design a form for login and sign up with Each box takes holds six eggs. Write a
into array and find highest value number. username and password. Write the program code for a Function EggsInto
complete code Use the database name Boxes that takes integer parameter,
Module Program
BCA and Table name tblUserdetal NumberOfEggs from the user. The
Sub Main() procedure is to calculate how many egg
Imports [Link]
[Link]("Enter number of elements: boxes can be filled and left over.
Public Class LoginForm
") Module Program
Private connectionString As String =
Dim n As Integer = Sub Main()
"Data Source=YourServer;Initial
[Link]([Link]())
Catalog=BCA;Integrated Security=True"
Dim numbers(n - 1) As Integer [Link]("Enter the number of eggs: ")
Private connection As SqlConnection
For i As Integer = 0 To n - 1 Dim numberOfEggs As Integer =
Private Sub LoginForm_Load(sender As [Link]([Link]())
[Link]("Enter number " & (i + 1) & Object, e As EventArgs) Handles
": ") [Link] Dim numberOfBoxes As Integer
numbers(i) = [Link] connection = New Dim eggsLeftOver As Integer
([Link]()) SqlConnection(connectionString)
Next EggsIntoBoxes(numberOfEggs,
End Sub
numberOfBoxes, eggsLeftOver)
Dim highest As Integer = numbers(0) Private Sub btnLogin_Click(sender As
Object, e As EventArgs) Handles [Link]("Number of boxes:
For i As Integer = 1 To n - 1
[Link] " & numberOfBoxes)
If numbers(i) > highest Then
Dim username As String = [Link]("Eggs left over: " &
highest = numbers(i) [Link] eggsLeftOver)
End If Dim password As String = [Link]()
Next [Link]
Dim query As String = "SELECT COUNT End Sub
[Link]("Highest:" & highest)
(*) FROM tblUserdetail WHERE Username Function EggsIntoBoxes(ByVal
[Link]() = @Username AND Password = Password" numberOfEggs As Integer, ByRef
End Sub [Link]() numberOfBoxes As Integer, ByRef
End Module eggsLeftOver As Integer)
Dim command As New
SqlCommand(query, connection) numberOfBoxes = numberOfEggs \ 6
WAP to calculates factorial for a given [Link]("@Us eggsLeftOver = numberOfEggs Mod 6
number using a recursive function. ername", username)
Module Program [Link]("@Pa End Function
ssword", password) End Module
Sub Main()
Dim result As Integer =
[Link]("Enter a number: ")
Convert.ToInt32([Link]())
Dim number As Integer =
If result > 0 Then
[Link]([Link]())
[Link]("Login successful")
[Link]("Factorial of " &
Else
number & " is: " & Factorial(number))
[Link]("Login Unsuccess ")
[Link]()
End If
End Sub
[Link]()
Function Factorial(ByVal n As Integer)
As Integer End Try
If n = 0 Then End Sub
Return 1 Private Sub btnSignUp_Click(sender As
Object, e As EventArgs) Handles
Else
[Link]
Return n * Factorial(n - 1)
Dim signUpForm As New SignUpForm()
End If
[Link]()
End Function
[Link]()
End Module
End Sub
End Class
To design an interface for new Supplier Write a program to find out the prime or
Write a Program to check whether the registration and to capture the Supplier composite numbers by taking input from
given string is palindrome or not. Id, Name, Address, City and to store all user.
these fields data into the database in
Module Program TblSupplier. Module Program

Sub Main() Imports [Link] Sub Main(args As String())


[Link]("Enter a string: ") [Link]("Enter a number: ")
Public Class SupplierRegistrationForm
Dim inputString As String =
[Link]() Private connectionString As String = "Data Dim number As Integer =
Source=YourServer;Initial [Link]([Link]())
If IsPalindrome(inputString) Then
Catalog=YourDatabase;Integrated If IsPrime(number) Then
[Link]("Is a palindrome.") Security=True"
Else [Link]($"{number} is a prime
Private Sub btnSubmit_Click(sender As number.")
[Link]("Not a palindrome.") Object, e As EventArgs) Handles
End If [Link] Else
[Link]() Dim supplierId As Integer = [Link]($"{number} is a
End Sub [Link]([Link]) composite number.")
Function IsPalindrome(ByVal str As Dim name As String = [Link] End If
String) As Boolean
str = [Link]() Dim address As String = [Link] [Link]()

Dim alphanumericStr As String = Dim city As String = [Link] End Sub


[Link]
lace(str, "[^a-zA-Z0-9]", "") Dim query As String = "INSERT INTO Function IsPrime(number As Integer) As
TblSupplier (SupplierId, Name, Address, Boolean
Dim left As Integer = 0
City) VALUES (@SupplierId, @Name,
Dim right As Integer = If number <= 1 Then
@Address, @City)"
[Link] - 1
Return False
Using connection As New
While left < right
SqlConnection(connectionString) End If
If alphanumericStr(left) <>
alphanumericStr(right) Then Using command As New For i As Integer = 2 To [Link](number)
Return False SqlCommand(query, connection)
If number Mod i = 0 Then
End If
[Link]("@Su Return False
left += 1
pplierId", supplierId)
right -= 1 End If
[Link]("@Na
End While me", name) Next
Return True [Link]("@Ad
dress", address) Return True
End Function [Link]("@Cit
End Function
End Module y", city)
End Module
[Link]()

[Link]()

[Link]("Supplier information
saved successfully.")

End Using

End Using

End Sub

End Class

You might also like