vb.net - 未加权 GPA 计算器代码代码问题
问题描述
我希望用户在 TextBox 中输入学分,从 ComboBox 中选择等级,以获得基于输入的学期课程编号生成的行数。生成行的代码在 Form1_Load 事件中,计算 GPA 的代码在 CHECK GPA 按钮中完成。我遇到的问题是如何保存所有的学分和成绩并计算它。这是代码:
Imports System.Windows.Forms
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Show()
Dim Answer As String '= InputBox("Enter number of rows:", "Input Row ", "0")
Dim Row As Integer '= CInt(Answer)
Dim Height As Integer
Dim Valid As Boolean = False
Do While Valid = False
Try
Dim Repeat = True
Do While Repeat = True
Answer = InputBox("Please Enter Number Of Semester Courses:", "GPA CHECKER", "0")
Row = CInt(Answer)
If Row > 0 And Row <= 13 Then
Repeat = False
Else
Repeat = True
End If
Loop
Valid = True
Catch ex As InvalidCastException
MsgBox("You Can Only Input Numbers!", MsgBoxStyle.Information)
Valid = False
End Try
Loop
For index As Integer = 1 To Row
Dim myPanel As New Panel
Dim myLabel As New Label
Dim myTextBox As New TextBox
Dim myComboBox As New ComboBox
myPanel.Name = "myPanel" + index.ToString
myPanel.Location = New Point(12, 70 + Height)
myPanel.Size = New Size(260, 34)
myLabel.Text = "Course" + index.ToString
myLabel.Size = New Size(80, 22)
myLabel.TextAlign = ContentAlignment.MiddleLeft
myLabel.Location = New Point(45, 12)
myTextBox.Name = "CreditHours"
myTextBox.Size = New Size(50, 22)
myTextBox.Location = New Size(125, 12)
myComboBox.Name = "Grade"
myComboBox.Size = New Size(50, 22)
myComboBox.Location = New Size(210, 12)
myComboBox.Items.Add("A+")
myComboBox.Items.Add("A")
myComboBox.Items.Add("B+")
myComboBox.Items.Add("B")
myComboBox.Items.Add("C+")
myComboBox.Items.Add("C")
myComboBox.Items.Add("D+")
myComboBox.Items.Add("D")
myComboBox.Items.Add("F")
myPanel.Controls.Add(myLabel)
myPanel.Controls.Add(myTextBox)
myPanel.Controls.Add(myComboBox)
Me.Controls.Add(myPanel)
Height += 34
Me.Show()
Next
End Sub
Private Sub btnCheckGpa_Click(sender As Object, e As EventArgs) Handles btnCheckGpa.Click
Form2.Show()
Me.Hide()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
解决方案
推荐阅读
- c++ - constexpr 中的构建错误
- vb.net - DataGridView 使用 bindingsouce 过滤文本框
- nginx - nginx反向代理到单独服务器上的https url导致444没有错误
- node.js - 如何为 winston@3 记录器制作自定义 json 格式化程序?
- ios - 索引分段控件的特定视图或标签
- java - 在他的 toString 方法中打印数组的索引
- visual-studio-code - Crystal Lang 中的 Hello World 未输出到终端
- android - 如何在 Spinner 上设置仅国旗
- android - Android Studio 3.1.3,设计视图总是空的 - 为什么开箱即用不能正常工作
- join - 如何在 Yii2 GridView 中显示多个关系记录?