0% found this document useful (0 votes)
21 views7 pages

VBNET Console HelpCodes

Binary trees

Uploaded by

inchristjoe
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)
21 views7 pages

VBNET Console HelpCodes

Binary trees

Uploaded by

inchristjoe
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

VISUAL BASIC.

NET CODES
PublicClassForm1

PrivateSub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Dim num1, num2, sum AsInteger
num1 = InputBox("Enter first number")
num2 = InputBox("Entr second number")
sum = num1 + num2
[Link] = sum
EndSub

PrivateSub Button2_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link] = Val([Link]) + Val([Link])
EndSub

PrivateSub Button3_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Dim num1, num2, total AsInteger
num1 = [Link]
num2 = [Link]
total = Val(num1) + Val(num2)
[Link] = total

EndSub
EndClass

________________________________________________________________
PublicClassForm1

PrivateSub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Dim num1 AsInteger, num2 AsInteger, num3 AsInteger
num1 = [Link]
num2 = [Link]
num3 = num1 + num2
[Link] = num3
[Link] = num3

EndSub
____________________________________________________________________

PrivateSub Form1_Load(ByVal sender As [Link], ByVal e As


[Link]) [Link]
[Link] = [Link]
EndSub

1 lovemoremanyeruke@[Link] 0777634287/0712389336
PrivateSub Button2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim x AsInteger, p AsInteger
For x = 0 To 100
p = x Mod 2
If p = 1 Then
[Link](x)
Else

EndIf
Next
EndSub
EndClass
____________________________________________________________________

ModuleModule1

Sub Main()
Dim num1, num2, total As Integer
[Link]("Enter first number")
num1 = [Link]()
[Link]("Enter second number")
num2 = [Link]()
total = num1 + num2
[Link]("Total is " & total)
[Link]()
EndSub

EndModule

____________________________________________________________________

PublicClassForm1
PrivateSub Button1_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
Dim a, b, c AsInteger, x, y AsDouble
a = InputBox("Enter the value for variable a")
b = InputBox("Enter the value for variable b")
c = InputBox("Enter the value for variable c")
If (b ^ 2 - 4 * a * c) > 0 Then
x = (-b + [Link](b ^ 2 - 4 * a * c)) / 2 * a
y = (-b - [Link](b ^ 2 - 4 * a * c)) / 2 * a
[Link]("The first root for the equation is
"& y)
[Link]("The second root for the equation is
"& x)

ElseIf (b ^ 2 - 4 * a * c) = 0 Then
x = (-b) / 2 * a

2 lovemoremanyeruke@[Link] 0777634287/0712389336
[Link]("The only root for the equation is "&
x)
Else
MsgBox("The has no real roots")
EndIf

EndSub
EndClass
________________________________________________________________
PublicClassForm1

PrivateSub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Dim names AsString
Dim count AsInteger
Dim names1 AsString
names1 = ""
names = InputBox("Enter a string")
For count = Len(names) To 1 Step -1
names1 = names1 + Mid(names, count, 1)
Next count
If names = names1 Then
[Link]("The word "& names &" is a
palindrome")
MsgBox("The word "& (names) &" is a palindrome")
Else
[Link]("The word "& names &" is not a
palindrome")
MsgBox("The word "& (names) &" is not a palindrome")
EndIf
EndSub
____________________________________________________________________
__________________________
PrivateSub Button2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim x, y AsInteger
For x = 620 To 500 Step -1
y = x Mod 2
If y = 1 Then
[Link](x)
Else
[Link](x)
EndIf
Next
EndSub
EndClass

________________________________________________________________
ModuleModule1
Function Add(ByVal a, ByVal b) AsInteger
3 lovemoremanyeruke@[Link] 0777634287/0712389336
Add = a + b
EndFunction
Sub Main()
Dim fn, sn, answer AsInteger
[Link]("Enter first number")
fn = [Link]()
[Link]("Enter first number")
sn = [Link]()
answer = Add(fn, sn)
[Link]("The sum is "& answer)
[Link]()
EndSub

EndModule
________________________________________________________________
PublicClassForm1

PrivateSub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Dim x, mark AsInteger
For x = 1 To 2
mark = InputBox("Enter a mark")
If mark < 0 Or mark > 100 Then
MsgBox("Enter a mark from 0 to 100 only")
Else
SelectCase mark
CaseIs>= 70 ', Is <= 100
'MsgBox("Grade A")
[Link]("The grade of the mark "&
mark &" is A")
Case 65 To 69
'MsgBox("Grade B")
[Link]("The grade of the mark "&
mark &" is B")
Case 55 To 64
'MsgBox("Grade C")
[Link]("The grade of the mark "&
mark &" is C")
Case 50 To 54
'MsgBox("Grade D")
[Link]("The grade of the mark "&
mark &" is D")
Case 40 To 49
'MsgBox("Grade E")
[Link]("The grade of the mark "&
mark &" is E")
Case 35 To 39
'MsgBox("Grade O")
[Link]("The grade of the mark "&
mark &" is O")

4 lovemoremanyeruke@[Link] 0777634287/0712389336
Case Else
'MsgBox("Grade F")
[Link]("The grade of the mark "&
mark &" is F")
EndSelect
EndIf

Next

If mark < 0 Or mark > 100 Then x = -1


EndSub
____________________________________________________________________
__________________
PrivateSub Button2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim x, mark AsInteger
x = 0
DoWhile x < 2
mark = InputBox("Enter a mark")
If mark > 0 And mark <= 100 Then
SelectCase mark
CaseIs>= 70 ', Is <= 100
'MsgBox("Grade A")
[Link]("The grade of the mark "&
mark &" is A")
Case 65 To 69
'MsgBox("Grade B")
[Link]("The grade of the mark "&
mark &" is B")
Case 55 To 64
'MsgBox("Grade C")
[Link]("The grade of the mark "&
mark &" is C")
Case 50 To 54
'MsgBox("Grade D")
[Link]("The grade of the mark "&
mark &" is D")
Case 40 To 49
'MsgBox("Grade E")
[Link]("The grade of the mark "&
mark &" is E")
Case 35 To 39
'MsgBox("Grade O")
[Link]("The grade of the mark "&
mark &" is O")
Case Else
'MsgBox("Grade F")
[Link]("The grade of the mark "&
mark &" is F")
EndSelect

5 lovemoremanyeruke@[Link] 0777634287/0712389336
EndIf
x += 1
Loop
EndSub
__
____________________________________________________________________
__________________
PrivateSub Button3_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim x, mark AsInteger
x = 0
Do
mark = InputBox("Enter a mark")
If mark > 0 And mark <= 100 Then
SelectCase mark
CaseIs>= 70 ', Is <= 100
'MsgBox("Grade A")
[Link]("The grade of the mark "&
mark &" is A")
Case 65 To 69
'MsgBox("Grade B")
[Link]("The grade of the mark "&
mark &" is B")
Case 55 To 64
'MsgBox("Grade C")
[Link]("The grade of the mark "&
mark &" is C")
Case 50 To 54
'MsgBox("Grade D")
[Link]("The grade of the mark "&
mark &" is D")
Case 40 To 49
'MsgBox("Grade E")
[Link]("The grade of the mark "&
mark &" is E")
Case 35 To 39
'MsgBox("Grade O")
[Link]("The grade of the mark "&
mark &" is O")
Case Else
'MsgBox("Grade F")
[Link]("The grade of the mark "&
mark &" is F")
EndSelect
EndIf
x += 1
LoopUntil x = 2
EndSub

6 lovemoremanyeruke@[Link] 0777634287/0712389336
____________________________________________________________________
__________________
PrivateSub Button4_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim names(4) AsString
Dim x, y AsInteger, temp AsString
x = 0
DoWhile x < 5
names(x) = InputBox("Enter a name")
[Link](names(x))
x += 1
Loop
For x = 0 To 4
For y = 0 To 3
If names(y) > names(y + 1) Then
temp = names(y)
names(y) = names(y + 1)
names(y + 1) = temp
EndIf
Next
Next
x = 0
[Link]()
[Link]()
Do
[Link](names(x))
[Link](names(x))

x = x + 1
LoopUntil x = 5
EndSub

____________________________________________________________________
__________________
PrivateSub Button5_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim names(4) AsString
Dim x AsInteger
x = 0
[Link]()
DoWhile x < 5
names(x) = InputBox("Enter a name")
[Link] = True
x += 1
Loop
EndSub
EndClass

7 lovemoremanyeruke@[Link] 0777634287/0712389336

You might also like