2016-04-26 12 views
0

Ich habe eine einfache Frage. Alles, was ich tun muss, ist, die Array-Informationen aus dem ausgewählten Kombinationsfeld zu holen. Ich weiß über combobox.selectedindex, aber das ist nicht mein Problem. Ich muss die Array-Informationen abrufen. Sobald ich den Namen des Schülers gewählt habe, wird der ursprüngliche Grad und der Grad des gebogenen Buchstabens angezeigt. Ich habe die Mathematik schon gemacht, ich habe alles außer diesem gemacht. Hier ist mein Code.Abrufen von Array-Informationen aus dem ausgewählten Combobox-Objekt.

 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 

Ich würde auch dann müssen die Informationen aus diesem und berechnen ihre Punktzahl holen als gegeben und nach hinten schieben, um die Textfelder, die ich tun kann.

Würde ich nur

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

oder so ähnlich, dass ich weiß, dass auf jeden Fall falsch ich gerade zeigt y'all mein Konzept des Denkens. Irgendwelche Fragen bitte fragen Ich werde mein bestes versuchen, sie zu erklären. Aber das ist buchstäblich alles was ich brauche und ich bin fertig mit meinem Programm haha.

Antwort

0

Es wäre hilfreich, wenn Sie gepostet haben, wie StudentData_Person definiert ist.

Ich empfehle, ein neues Curved_String-Feld zu StudentData_Person hinzuzufügen. Und bevölkern Sie es, wenn Sie die gekrümmte Note berechnet haben. Dann tust du es einfach.

originalscore_textbox.text = StudentData_Person(SelectedIndex).Grade_String 
curvedgrade_textbox.text = StudentData_Person(SelectedIndex).Curved_String 
Verwandte Themen