追蹤
ˊ-橙色九月-ˊ
關於部落格
  • 32952

    累積人氣

  • 8

    今日人氣

    0

    追蹤人氣

VB6

第一題
Dim nstart As Integer
Dim nend As Integer
Dim i As Integer
Dim degree As Double

If Not t1.Text = "" Or Not t2.Text = "" Then
nstart = CInt(t1.Text)
nend = CInt(t2.Text)
degree = 1.0
If nstart < nend Then
For i = nstart To nend
degree = degree * i
Next
End If
If nend < nstart Then
For i = nend To nstart
degree = degree * i
Next
End If
End If
l1.Text = "從" & nstart & "到" & nend & "的乘積為" & degree

第二題
'宣告變數
Dim e1 As Double
Dim e2 As Double
Dim e3 As Double
Dim c1 As Double
Dim en1 As Double
Dim average As Double
If Not t1.Text = "" Or Not t2.Text = "" Or Not t3.Text = "" Or Not t4.Text = "" Or Not t5.Text = "" Then
'轉換資料型態 , 文字轉換成數字
e1 = CDbl(t1.Text)
e2 = CDbl(t2.Text)
e3 = CDbl(t3.Text)
c1 = CDbl(t4.Text)
en1 = CDbl(t5.Text)

Dim fe() As Double = {e1, e2, e3, c1, en1}
'計算平均值
average = (e1 + e2 + e3 + c1 + en1) / 5    '計算平均值

'輸出結果
l1.Text = "原始資料:" & vbCrLf
'l1.Text &= exam01 & " , " & exam02 & " , " & exam03 & ", " & mideram & ", " & finaleram & ""
l1.Text &= fe(0) & ","
l1.Text &= fe(1) & ","
l1.Text &= fe(2) & ","
l1.Text &= fe(3) & ","
l1.Text &= fe(4)
l1.Text &= vbCrLf & "平均成績:" & vbCrLf & average
End If

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