我是MIPS的新手。我正在开展一项更大的任务来学习这门语言。该任务要求我从用户处取一个字符串。这是我的代码:
Option Explicit
Private Sub Form_Load()
Dim CN As ADODB.Connection
Dim RS As ADODB.Recordset
With MSChart1
.TitleText = "Counts of Student Grades in 10% Intervals"
With .Title.VtFont
.Size = 14
.Style = VtFontStyleBold
.VtColor.Set 32, 96, 192
End With
With .Plot
With .Wall.Brush
.Style = VtBrushStyleSolid
.FillColor.Set 255, 255, 255
End With
With .Axis(VtChAxisIdY).ValueScale
.Auto = False
.Maximum = 15
.Minimum = 0
.MajorDivision = 3
.MinorDivision = 2
End With
With .SeriesCollection.Item(1).DataPoints.Item(-1)
With .Brush
.Style = VtBrushStyleSolid
.FillColor.Set 192, 224, 255
End With
With .DataPointLabel
.LocationType = VtChLabelLocationTypeAbovePoint
.VtFont.Style = VtFontStyleBold
End With
End With
End With
End With
Set CN = New ADODB.Connection
CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Exclusive;" _
& "Data Source='grades.mdb'"
On Error Resume Next 'In case previous run failed try dropping this here.
CN.Execute "DROP TABLE [TempGrades]", , adCmdText Or adExecuteNoRecords
On Error GoTo 0
'Create TempGrades table containing CalcRange values so we can do a
'LEFT OUTER JOIN to the GradeRanges table. This allows us to plot
'the ranges with a Count of 0 in them:
CN.Execute "SELECT [Grade], ([Grade] \ 10) * 10 AS [CalcRange] " _
& "INTO [TempGrades] FROM [Grades]", _
, _
adCmdText Or adExecuteNoRecords
Set RS = New ADODB.Recordset
With RS
.CursorLocation = adUseClient
.Open "SELECT CStr([GradeRange]) & '%', COUNT([Grade]) AS [Count] " _
& "FROM [GradeRanges] LEFT OUTER JOIN [TempGrades] " _
& "ON [GradeRanges].[GradeRange] = [TempGrades].[CalcRange] " _
& "GROUP BY [GradeRange] " _
& "ORDER BY [GradeRange]", _
CN, _
adOpenStatic, _
adLockReadOnly, _
adCmdText
.MoveFirst 'Important, otherwise MSChart will lose the 1st row data!
'Also note that the 1st column MUST BE String data or it
'will not be used as X-axis Label values.
Set MSChart1.DataSource = RS
.Close
End With
CN.Execute "DROP TABLE [TempGrades]", , adCmdText Or adExecuteNoRecords
CN.Close
End Sub
Private Sub Form_Resize()
If WindowState <> vbMinimized Then
MSChart1.Move 0, 0, ScaleWidth, ScaleHeight
End If
End Sub
程序运行并要求输入。但是按下回车后它会以错误结束。有人能帮助我理解为什么会这样吗?
答案 0 :(得分:0)
我意识到main必须高于我定义的所有其他函数。