Private Sub Form_Load()
Show
Dim stuname(5) As String * 10, score(4, 3) As Single
stuname(1) = "张三": stuname(2) = "李四": stuname(3) = "王五": stuname(4) = "赵六"
score(1, 1) = "78": score(1, 2) = "96.5": score(1, 3) = "75"
score(2, 1) = "85": score(2, 2) = "75": score(2, 3) = "96"
score(3, 1) = "99": score(3, 2) = "89": score(3, 3) = "88"
score(4, 1) = "69": score(4, 2) = "72.6": score(4, 3) = "80"
FontName = "黑体": FontSize = 14: FontUnderline = True: FontBold = True
Print Tab(13); "考试成绩统计表"
Print
FontName = "system"
Print "姓名"; Tab(15); "语文"; Tab(25); "数学"; Tab(35); "物理"; Tab(45); "总分"
FontUnderline = False
Print
For i = 1 To 4
Print stuname(i);
Print Tab(15); Format(score(i, 1), "####.0");
Print Tab(25); Format(score(i, 2), "####.0");
Print Tab(35); Format(score(i, 3), "####.0");
sumscore = score(i, 1) + score(i, 2) + score(i, 3)
Print Tab(45); Format(sumscore, "####.0")
sumyw = sumyw + score(i, 1)
sumsx = sumsx + score(i, 2)
sumwl = sumwl + score(i, 3)
Next i
Sum = sumyw + sumsx + sumwl
Print
FontItalic = True
FontUnderline = True
Print "平均";
Print Tab(13); Format(sumyw / 4, "###.0");
Print Tab(22); Format(sumsx / 4, "###.0");
Print Tab(31); Format(sumwl / 4, "###.0");
Print Tab(40); Format(Sum / 4, "###.0")
End Sub
按照上边的代码,在平均那一行的四个数字都没有和上面的数字对齐,后来我把tab的值改成下面的才对齐:
Print Tab(13); Format(sumyw / 4, "###.0");
Print Tab(22); Format(sumsx / 4, "###.0");
Print Tab(31); Format(sumwl / 4, "###.0");
Print Tab(40); Format(Sum / 4, "###.0")
。。。。
我的问题是:课本例题错了,还是我的VB程序错了,还是我错了。如果我错了,错在什么地方?
在VB贴吧里问了。有位大哥说把“平均”两个属性设置成注释就可以格式对齐了。我当时试了。格式是对齐了,可是发现效果没了。
在这边再求助一下。。。
Show
Dim stuname(5) As String * 10, score(4, 3) As Single
stuname(1) = "张三": stuname(2) = "李四": stuname(3) = "王五": stuname(4) = "赵六"
score(1, 1) = "78": score(1, 2) = "96.5": score(1, 3) = "75"
score(2, 1) = "85": score(2, 2) = "75": score(2, 3) = "96"
score(3, 1) = "99": score(3, 2) = "89": score(3, 3) = "88"
score(4, 1) = "69": score(4, 2) = "72.6": score(4, 3) = "80"
FontName = "黑体": FontSize = 14: FontUnderline = True: FontBold = True
Print Tab(13); "考试成绩统计表"
FontName = "system"
Print "姓名"; Tab(15); "语文"; Tab(25); "数学"; Tab(35); "物理"; Tab(45); "总分"
FontUnderline = False
For i = 1 To 4
Print stuname(i);
Print Tab(15); Format(score(i, 1), "####.0");
Print Tab(25); Format(score(i, 2), "####.0");
Print Tab(35); Format(score(i, 3), "####.0");
sumscore = score(i, 1) + score(i, 2) + score(i, 3)
Print Tab(45); Format(sumscore, "####.0")
sumyw = sumyw + score(i, 1)
sumsx = sumsx + score(i, 2)
sumwl = sumwl + score(i, 3)
Next i
Sum = sumyw + sumsx + sumwl
FontItalic = True
FontUnderline = True
Print "平均";
Print Tab(13); Format(sumyw / 4, "###.0");
Print Tab(22); Format(sumsx / 4, "###.0");
Print Tab(31); Format(sumwl / 4, "###.0");
Print Tab(40); Format(Sum / 4, "###.0")
End Sub
按照上边的代码,在平均那一行的四个数字都没有和上面的数字对齐,后来我把tab的值改成下面的才对齐:
Print Tab(13); Format(sumyw / 4, "###.0");
Print Tab(22); Format(sumsx / 4, "###.0");
Print Tab(31); Format(sumwl / 4, "###.0");
Print Tab(40); Format(Sum / 4, "###.0")
。。。。
我的问题是:课本例题错了,还是我的VB程序错了,还是我错了。如果我错了,错在什么地方?
在VB贴吧里问了。有位大哥说把“平均”两个属性设置成注释就可以格式对齐了。我当时试了。格式是对齐了,可是发现效果没了。
在这边再求助一下。。。