字體:小 中 大 | |
|
|
2010/04/12 18:31:33瀏覽314|回應0|推薦0 | |
Public Class Form1 Dim a(7), b(7), c(7) As Control Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load a(1) = Label1 : a(2) = Label2 : a(3) = Label3 : a(4) = Label4 : a(5) = Label5 : a(6) = Label6 : a(7) = Label7 b(1) = TextBox1 : b(2) = TextBox2 : b(3) = TextBox3 : b(4) = TextBox4 : b(5) = TextBox5 : b(6) = TextBox6 : b(7) = TextBox7 c(1) = Label8 : c(2) = Label9 : c(3) = Label10 : c(4) = Label11 : c(5) = Label12 : c(6) = Label13 : c(7) = Label14 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim week As String Dim c1, c2, c3, c4, ctoday, ctotal As Integer Dim W(7), car(4) As Integer FileOpen(1, "c:/940307.sm", OpenMode.Input) For i = 1 To 7 W(i) = 0 Next ctotal = 0 Do While Not EOF(1) Input(1, week) ctoday = 0 Input(1, c1) : Input(1, c2) : Input(1, c3) : Input(1, c4) ctoday = c1 + c2 + c3 + c4 ctotal = ctotal + ctoday Select Case week Case "MONDAY" W(1) = W(1) + ctoday Case "TUESDAY" W(2) = W(2) + ctoday Case "WEDNESDAY" W(3) = W(3) + ctoday Case "THURSDAY" W(4) = W(4) + ctoday Case "FRIDAY" W(5) = W(5) + ctoday Case "SATURDAY" W(6) = W(6) + ctoday Case "SUNDAY" W(7) = W(7) + ctoday End Select Loop GroupBox2.Text = "依星期別" For i = 1 To 7 a(i).Text = "星期" & Mid("一二三四五六日", i, 1) b(i).Width = 300 * W(i) / ctotal c(i).Text = Format(W(i), "###,###") c(i).Left = b(i).Left + b(i).Width + 10 Next FileClose() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cTotal, car(4), c1, c2, c3, c4, T As Integer Dim week, type(4), TT As String FileOpen(1, "C:/940307.sm", OpenMode.Input) For i = 1 To 4 car(i) = 0 Next ctotal = 0 type(1) = "大型車" : type(2) = "中型車" : type(3) = "小型車" : type(4) = "公務車" Do While Not EOF(1) Input(1, week) Input(1, c1) : car(1) = car(1) + c1 Input(1, c2) : car(2) = car(2) + c2 Input(1, c3) : car(3) = car(3) + c3 Input(1, c4) : car(4) = car(4) + c4 ctotal = ctotal + c1 + c2 + c3 + c4 Loop FileClose() '排序 For i = 1 To 3 For j = 1 To 4 - i If car(j) > car(j + 1) Then T = car(j) : car(j) = car(j + 1) : car(j + 1) = T TT = type(j) : type(j) = type(j + 1) : type(j + 1) = TT End If Next Next '結束 GroupBox2.Text = "依車輛別" For i = 1 To 7 If i <= 4 Then a(i).Text = type(i) b(i).Width = 300 * car(i) / cTotal c(i).Text = Format(car(i), "###,###") c(i).Left = b(i).Left + b(i).Width + 10 Else a(i).Text = "" b(i).Width = 0 c(i).Text = "" End If Next End Sub End Class |
|
( 心情隨筆|心情日記 ) |