CODE VB2

<TIM NAM DUONG LICH>

Dim y, c, n As Integer

Dim p, k As String

y = Val(Text1.Text)

c = y Mod 10

n = y Mod 12

Select Case c

Case 0

p = "canh"

Case 1

p = "tan"

Case 2

p = "nham"

Case 3

p = "quy"

Case 4

p = "giap"

Case 5

p = "at"

Case 6

p = "binh"

Case 7

p = "dinh"

Case 8

p = "mau"

Case 9

p = "ky"

End Select

Select Case n

Case 0

k = "than"

Case 1

k = "dau"

Case 2

k = "tuat"

Case 3

k = "hoi"

Case 4

k = "ty"

Case 5

k = "suu"

Case 6

k = "dan"

Case 7

k = "meo"

Case 8

k = "thin"

Case 9

k = "ty"

Case 10

k = "ngo"

Case 11

k = "mui"

End Select

Text2.Text = p & " " & k

-----------------------------------------------------------

<GIAI PT BAC 2>

Dim a, b, c, d, x, x1, x2 As Double

a = Text1.Text

b = Text2.Text

c = Text3.Text

d = (b * b) - (4 * a * c)

If d < 0 Then

tb = " PT vo nghiem "

Text4.Text = tb

End If

If d = 0 Then

tb = " PT co nghiem kep "

x = -b / (2 * a)

Text4.Text = tb

Text5.Text = x

End If

If d > 0 Then

tb = " PT co 2 nghiem phan biet"

x1 = (-b + Sqr(d)) / (2 * a)

x2 = (-b - Sqr(d)) / (2 * a)

Text4.Text = tb

Text5.Text = x1

Text6.Text = x2

-----------------------------------------------------------------

<TINH + ->

f Me.Text3.Text = "+" Then

Me.Text4.Text = CInt(Me.Text1.Text) + CInt(Me.Text2.Text)

Else

If Me.Text3.Text = "-" Then

Me.Text4.Text = CInt(Me.Text1.Text) - CInt(Me.Text2.Text)

Else

If Me.Text3.Text = "*" Then

Me.Text4.Text = CInt(Me.Text1.Text) * CInt(Me.Text2.Text)

Else

Me.Text4.Text = CInt(Me.Text1.Text) / CInt(Me.Text2.Text)

End If

End If

End If

-----------------------------------------------------

<TONG 2>

<TONG>

Dim i, n As Integer

VScroll1.Value = Val(Text1.Text)

VScroll2.Value = Val(Text3.Text)

n = 0

For i = VScroll1.Value To VScroll2.Value

n = n + i

Next

Text2.Text = n

<TONG LE>

Dim i, n As Integer

VScroll1.Value = Val(Text1.Text)

VScroll2.Value = Val(Text3.Text)

n = 0

For i = VScroll1.Value To VScroll2.Value

If i Mod 2 <> 0 Then

n = n + i

End If

Next

Text2.Text = n

<TONG CHAN>

Dim i, n As Integer

VScroll1.Value = Val(Text1.Text)

VScroll2.Value = Val(Text3.Text)

n = 0

For i = VScroll1.Value To VScroll2.Value

If i Mod 2 = 0 Then

n = n + i

End If

Next

Text2.Text = n

<KHAI BAO>

Text3.Text = VScroll2.Value

Text1.Text = VScroll1.Value

----------------------------------------------------

<SAP XEP TANG>

Dim i, j, n, x As Integer

Dim a(7) As Integer

n = 7

a(1) = Val(Text1.Text)

a(2) = Val(Text2.Text)

a(3) = Val(Text3.Text)

a(4) = Val(Text4.Text)

a(5) = Val(Text5.Text)

a(6) = Val(Text6.Text)

a(7) = Val(Text7.Text)

For i = 1 To n - 1 Step 1

For j = i + 1 To n Step 1

If a(j) < a(i) Then

x = a(i)

a(i) = a(j)

a(j) = x

End If

Next j

Next i

Text8 = a(1)

Text9 = a(2)

Text10 = a(3)

Text11 = a(4)

Text12 = a(5)

Text13 = a(6)

Text14 = a(7)

End Sub

Private Sub Command2_Click()

Dim i, j, n, x As Integer

Dim a(7) As Integer

n = 7

a(1) = Val(Text1.Text)

a(2) = Val(Text2.Text)

a(3) = Val(Text3.Text)

a(4) = Val(Text4.Text)

a(5) = Val(Text5.Text)

a(6) = Val(Text6.Text)

a(7) = Val(Text7.Text)

For i = 1 To n - 1 Step 1

For j = i + 1 To n Step 1

If a(j) > a(i) Then

x = a(i)

a(i) = a(j)

a(j) = x

End If

Next j

Next i

Text8 = a(1)

Text9 = a(2)

Text10 = a(3)

Text11 = a(4)

Text12 = a(5)

Text13 = a(6)

Text14 = a(7)

End Sub

Private Sub Command3_Click()

Dim i, j, x, n As Integer

n = 7

ReDim a(n + 1) As Integer

a(1) = Text8

a(2) = Text9

a(3) = Text10

a(4) = Text11

a(5) = Text12

a(6) = Text13

a(7) = Text14

x = Text15

i = 1

Do While x > a(i)

i = i + 1

Loop

For j = 0 To n - 1

a(n - j + 1) = a(n - j)

Next

a(i) = x

Text16 = a(1)

Text17 = a(2)

Text18 = a(3)

Text19 = a(4)

Text20 = a(5)

Text21 = a(6)

Text22 = a(7)

Text23 = a(8)

i = n

---------------------------------

<SAP XEP GIAM>

Dim i, j, n, x As Integer

Dim a(7) As Integer

n = 7

a(1) = Val(Text1.Text)

a(2) = Val(Text2.Text)

a(3) = Val(Text3.Text)

a(4) = Val(Text4.Text)

a(5) = Val(Text5.Text)

a(6) = Val(Text6.Text)

a(7) = Val(Text7.Text)

For i = 1 To n - 1 Step 1

For j = i + 1 To n Step 1

If a(j) > a(i) Then

x = a(i)

a(i) = a(j)

a(j) = x

End If

Next j

Next i

Text8 = a(1)

Text9 = a(2)

Text10 = a(3)

Text11 = a(4)

Text12 = a(5)

Text13 = a(6)

Text14 = a(7)

End Sub

-----------------------------------------------

<CHEN>

Dim i, j, x, n As Integer

n = 7

ReDim a(n + 1) As Integer

a(1) = Text8

a(2) = Text9

a(3) = Text10

a(4) = Text11

a(5) = Text12

a(6) = Text13

a(7) = Text14

x = Text15

i = 1

Do While x > a(i)

i = i + 1

Loop

For j = 0 To n - 1

a(n - j + 1) = a(n - j)

Next

a(i) = x

Text16 = a(1)

Text17 = a(2)

Text18 = a(3)

Text19 = a(4)

Text20 = a(5)

Text21 = a(6)

Text22 = a(7)

Text23 = a(8)

i = n

-----------------------------------------------------------

<SO NGUYEN TO>

Dim n, i As Integer

n = Text1.Text

i = 2

Do While (i <= Sqr(n)) And (n Mod i <> 0)

i = i + 1

Loop

If (i > Sqr(n)) And (n <> 1) Then

Text2.Text = "La so nguyen to"

Else

Text2.Text = "Khong phai la so nguyen to"

End If

---------------------------------------------------------------

<

Bạn đang đọc truyện trên: truyentop.pro

Tags: