2016-04-26 33 views
0

私は簡単な質問があります。私がする必要があるのは、選択したコンボボックスの項目から配列情報を取得することだけです。私はcombobox.selectedindexについて知っていますが、それは私の問題ではありません。配列情報を取得する必要があるので、生徒名を選択すると、元の等級と曲線文字の等級が表示されます。私はすでに数学をやったことがあります。ここに私のコードです。選択したコンボボックス項目から配列情報を取得します。

 Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click 

    Dim Line_String As String 

    Dim ArraySize_Integer As Integer = 0 
    Dim Grades_StreamReader As IO.StreamReader 
    Dim i As Integer = 0 
    Dim GradesFile_String As String = "Grades.txt" 'To hold the filename for opening 
    Dim DialogResponse As DialogResult 
    Dim x_Integer As Integer 
    Dim Mean_Decimal As Double = 0 
    Dim Total_Integer As Double = 0 
    Dim sum As Double 
    Dim stDev As Double 
    Dim x As Integer 
    Dim y As Integer 
    Dim orgScore As Integer 


    'Prompt to open the file 

    'Set the initial folder to display 
    OpenFileDialog1.InitialDirectory = IO.Directory.GetCurrentDirectory 


    'Open the file 
    With OpenFileDialog1 
     'Begin in the current folder 
     .InitialDirectory = Directory.GetCurrentDirectory() 
     .FileName = "Grades.txt" 
     .Title = "Select File or Directory for File" 
     'Filter to show only .txt files 
     OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 
     'Display the open file dialog box 
     DialogResponse = .ShowDialog() 
    End With 
    'Get the filename 
    GradesFile_String = OpenFileDialog1.FileName 

    'Connect to the file 
    Grades_StreamReader = IO.File.OpenText(GradesFile_String) 
    'Read the file into a structure array until it runs out of data 
    Do Until Grades_StreamReader.Peek = -1 
     'Raed the data 
     Line_String = Grades_StreamReader.ReadLine 
     'Split the line into the fields 
     StringArray_String = Line_String.Split(","c) 
     'Dynamically size the array of structures 
     ReDim Preserve StudentData_Person(ArraySize_Integer) 
     'Assign the fields to the structure, trimming the space 
     StudentData_Person(ArraySize_Integer).Name_String = StringArray_String(0).Trim 
     StudentData_Person(ArraySize_Integer).Grade_String = StringArray_String(1).Trim 
     'Increment for the next array element 
     ArraySize_Integer += 1 
     'Populate the combo box 
     Students_ComboBox.Items.Add(StringArray_String(0)) 

    Loop 
    'Close the file 
    Grades_StreamReader.Close() 

    'Count the scores 
    'Convert from String to Integer 
    Scores_TextBox.Text = ArraySize_Integer.ToString 



    'Calculate the mean 

    If StudentData_Person.Length > 0 Then 
     For x_Integer = 0 To StudentData_Person.Length - 1 
      Total_Integer += CInt(StudentData_Person(x_Integer).Grade_String) 
     Next 
     Mean_Decimal = Total_Integer/StudentData_Person.Length 
    End If 
    Mean_TextBox.Text = Mean_Decimal.ToString 

    'Calculate the Standard Deviation 

    If StudentData_Person.Length > 0 Then 
     For x = 0 To StudentData_Person.Length - 1 
      sum += ((CInt(StudentData_Person(x).Grade_String) - Mean_Decimal)^2) 
     Next 
     stDev = Math.Round(Math.Sqrt(sum/(x - 1)), 2) 

    End If 
    stDev_TextBox.Text = stDev.ToString 

    'Get information from ComboBox Selected Entry 
    Students_ComboBox.SelectedIndex 

    'Determine letter grade 
    For y = 0 To StudentData_Person.Length 
     If CInt(StudentData_Person(x).Grade_String) >= Mean_Decimal + (1.5 * stDev) Then 
      CurvedGrade_TextBox.Text = "A" 
     End If 
     If (Mean_Decimal + (0.5 * stDev)) <= CInt(StudentData_Person(x).Grade_String) And CInt(StudentData_Person(x).Grade_String) < (Mean_Decimal + (1.5 * stDev)) Then 
      CurvedGrade_TextBox.Text = "B" 
     End If 
     If (Mean_Decimal - (0.5 * stDev)) <= CInt(StudentData_Person(x).Grade_String) And CInt(StudentData_Person(x).Grade_String) < (Mean_Decimal + (1.5 * stDev)) Then 
      CurvedGrade_TextBox.Text = "C" 
     End If 
     If (Mean_Decimal - (1.5 * stDev)) <= CInt(StudentData_Person(x).Grade_String) And CInt(StudentData_Person(x).Grade_String) < (Mean_Decimal + (1.5 * stDev)) Then 
      CurvedGrade_TextBox.Text = "D" 
     End If 
     If CInt(StudentData_Person(x).Grade_String) < (Mean_Decimal - (1.5 * stDev)) Then 
      CurvedGrade_TextBox.Text = "F" 
     End If 
    Next 
End Sub 
End Class 

私も、このから情報を取得し、与えられた自分のスコアを計算し、私が行うことができますテキストボックスに出戻ってそれをプッシュする必要があります。

私はちょうど

originalscore_textbox.text = StudentData_Person(SelectedIndex) 
    curvedgrade_textbox.text = 'something like what's above this line 

または私はそれは私がちょうどy'allのに思考の私の概念を示すのです間違いなく間違っていることを知っているというようなことをするでしょう。何か質問がありましたら、私はそれらを説明するために最善を尽くして尋ねてください。しかし、これは文字通り私が必要としているものであり、私は自分のプログラムで頑張っています。

答えて

0

StudentData_Personの定義方法を投稿した場合に役立ちます。

新しいCurved_StringフィールドをStudentData_Personに追加することをお勧めします。曲がったグレードを計算したら、それを入力します。それでは、あなただけです。

originalscore_textbox.text = StudentData_Person(SelectedIndex).Grade_String 
curvedgrade_textbox.text = StudentData_Person(SelectedIndex).Curved_String 
関連する問題