ALL the new life
關於部落格
開心就好 ,生活就是要活的自在快樂 。 

  • 1355

    累積人氣

  • 0

    今日人氣

    0

    訂閱人氣

VB

1^1+2^2+3^3...n^n=
Private Sub Command1_Click()

    Dim a As Double

    Dim q As Double

    Dim z As Integer

    Dim i As Integer

    Dim j As Integer

   

    q = 0

    For i = 1 To Val(Text1.Text)

        a = 1

        For j = 1 To i

            a = a * i

        Next j

        q = q + a

    Next i

    Label2.Caption = "1^1+2^2+3^3+....+n^n=" & q

End Sub

 

 

Private Sub Form_Load()

    Label1.Caption = "n="

    Label1.FontSize = 15

    Text1.Text = ""

    Command1.Caption = "計算"

    Label2.Caption = ""

    Form1.Caption = "1^1+2^2+3^3...n^n="

End Sub


九九乘法

Private Sub Command1_Click()

    Dim a As Integer

    For a = 1 To 9

        Print a; "*1="; a * 1, a; "*2="; a * 2, a; "*3="; a * 3, a; "*4="; a * 4, a; "*5="; a * 5, a; "*6="; a * 6, a; "*7="; a * 7, a; "*8="; a * 8, a; "*9="; a * 9

        Next a

End Sub

 

 

Private Sub Form_Load()

    Form1.Caption = "九九乘法"

    Command1.Caption = "計算"

End Sub


2+4+...+100的總和

Private Sub C1_Click()

    Dim i As Long

    Dim a As Integer

   

    Do While i <= 100

        a = a + i

        i = i + 2

        Loop

    Q = "總合為" & a

    W = "2+4+...+100的總和"

  

    ENDVALUE = MsgBox(Q, , W)

   

   

End Sub

 

 

Private Sub C2_Click()

    Dim i As Long

    Dim a As Integer

   

    Do Until i > 100

        a = a + i

        i = i + 2

        Loop

    Q = "總合為" & a

    W = "2+4+...+100的總和"

  

    ENDVALUE = MsgBox(Q, , W)

   

End Sub

 

 

Private Sub C3_Click()

    Dim i As Long

    Dim a As Integer

   

    Do

        a = a + i

        i = i + 2




成績

Private Sub Command1_Click()

    q = Val(InputBox("請輸入學生1的數學成績", "輸入成績", ""))

    a = Val(InputBox("請輸入學生1的英文成績", "輸入成績", ""))

    z = Val(InputBox("請輸入學生2的數學成績", "輸入成績", ""))

    w = Val(InputBox("請輸入學生2的英文成績", "輸入成績", ""))

    s = Val(InputBox("請輸入學生3的數學成績", "輸入成績", ""))

    x = Val(InputBox("請輸入學生3的英文成績", "輸入成績", ""))

   

 

    Print "學生", "數學", "英文", "總分", "平均"

    Print "-----------------------------------------------------------------------------------------------"

    Print "學生1", q, a, q + a, (q + a) / 2

    Print "學生2", z, w, z + w, (z + w) / 2

    Print "學生3", s, x, s + x, (s + x) / 2

End Sub

 

 

Private Sub Form_Load()

    Form1.Caption = "成績"

    Command1.Caption = "計算"

End Sub


2~100質數

Private Sub Command1_Click()

    Dim l As Integer

    Dim p As Integer

    Dim i As Integer

    Dim j As Integer           

    l = 0

    p = 0

 

    For i = 2 To 100

    

        For j = 2 To (i - 1)

            If i Mod j = 0 Then

                j = i

            Else

                p = p + 1

            End If

        Next j

       

    If p = (i - 2) Then

        If i < 10 Then

            Print ;

        End If

        Print i,

        l = l + 1

        p = 0

    End If

       

    If l = 5 Then

        Print:

        l = 0

    End If

    p = 0

    Next i

End Sub

 

 

Private Sub Form_Load()

    Command1.Caption = "2~100質數"

End Sub



9*9

 

Private Sub Command1_Click()

    Dim I As Integer

    Dim A As Integer

   

    For I = 0 To 9 Step 2

   

        For A = O To 9 Step 2

            Print I; "*"; A; "="; Format(I * A, "00"),

        Next A

        Print

    Next I

End Sub


 

 

 

相簿設定
標籤設定
相簿狀態