Basic的并行数组雕刻器

Basic的并行数组雕刻器

本文介绍了使用Visual Basic的并行数组雕刻器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在编写一个程序,允许Carver教授根据他在输入框中输入的可能点数(strMax)来显示成绩.然后,用户在文本框中输入获得的积分(dblPoints)

然后我解决百分比. dblResults = dblPoints/CDbl(strMax)

第一步是将最小百分比存储在一维数组中.我做到了.

第二步是将等级存储在一维数组中.我做到了.

数组应为并行数组. < ------遇到问题

然后它应该显示来自strGrades数组的相应成绩< ----未完成.

我无法显示并行的数组.问题是for循环

我试过了

I''m writing a program the allows Professor Carver to display a grade based on the number of possible points he enters in the inputbox (strMax). Then the user enters the points he earned in the textbox (dblPoints)

Then I solve the percentage. dblResults = dblPoints/CDbl(strMax)

The first step is to store the minimum percentage points in one dimensional array. I did that.

The second step is to store the grades in one dimensional array. I did that.

The arrays should be parallel arrays. <------ Having trouble with it

It then should display the corresponding grade from the strGrades array <---- Not done.

I''m having trouble to display arrays in that are parallel. The problem is the for loop

I tried this

For intGrade As Integer = 0 To 4
         If dblResults <= dblPer(intGrade) Then
             lblGrade.Text = strGrade(intGrade + 1)
         ElseIf dblResults >= dblPer(0) Then
             lblGrade.Text = strGrade(0)
         Else
             lblGrade.Text = strGrade(4)
         End If
     Next intGrade


我收到错误消息:索引超出了数组的范围." strGrade(intGrade + 1)出了点问题,但不知道如何解决.

我也尝试过这种方式


I''m getting the error that says "Index was outside the bounds of the array." There''s something wrong with the strGrade(intGrade+1), but no idea how to fix this.

I also tried this way

For intGrade As Integer = 0 To 4
    If dblResults >= dblPer(intGrade) Then
        lblGrade.Text = strGrade(intGrade + 1)
    End If
Next intGrade



仍然出现相同的错误?

对if语句有帮助吗?我不明白怎么了.

谢谢.

这是您不理解的代码



Still getting the same error?

Any help with the if statements? I don''t understand what''s wrong.

Thanks.

Here is the code in case you don''t understand

Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        '' display the grade the student gets
        Dim dblPoints As Double
        Dim dblResults As Double
        Dim strGrade() As String =
            {"A", "B", "C", "D", "F"}
        Dim dblPer() As Double =
            {0.9, 0.8, 0.7, 0.6, 0.5}

        Double.TryParse(txtPoints.Text, dblPoints)
        '' displays the percentage the student recieves
        dblResults = dblPoints / CDbl(strMax)
        '' determines the grade

        For intGrade As Integer = 0 To 4
            If dblResults >= dblPer(intGrade) Then
                lblGrade.Text = strGrade(intGrade + 1)
            End If
        Next intGrade


    End Sub
   Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '' get the total number of possible points
        strMax =
            InputBox("Enter the total possible points.", "Professor Carver")

    End Sub

推荐答案


Dim dblPer() As Double =
    {0.9, 0.8, 0.7, 0.6, 0.5}



对此



to this

Dim dblPer() As Double =
    {0.9, 0.8, 0.7, 0.6, 0.0}



然后更改此



then change this

For intGrade As Integer = 0 To 4
    If dblResults >= dblPer(intGrade) Then
        lblGrade.Text = strGrade(intGrade + 1)
    End If
Next intGrade



对此



to this

For intGrade As Integer = 0 To dblPer.Length
    If dblResults >= dblPer(intGrade) Then
        lblGrade.Text = strGrade(intGrade)
        Exit For
    End If
Next intGrade



我知道有点晚了,但希望对您有所帮助.



A little late I know but I hope it helps.


这篇关于使用Visual Basic的并行数组雕刻器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:38