Created
April 7, 2016 04:53
-
-
Save tedliou/f82b0f08343a78be56854248d24420d0 to your computer and use it in GitHub Desktop.
姓名和分數的陣列運用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class Form1 | |
Dim name_(5) As String : Dim copy_name_(5) | |
Dim score_(5) As Integer : Dim copy_score_(5) | |
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click | |
TextBox1.Clear() | |
TextBox1.Text &= "名字" & vbTab & "分數" & vbNewLine | |
For j = 0 To 5 | |
name_(j) = InputBox("請輸入名字") | |
score_(j) = InputBox("請輸入分數") | |
TextBox1.Text &= name_(j) & vbTab & score_(j) & vbNewLine | |
Next | |
End Sub | |
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click | |
TextBox2.Clear() | |
name_.CopyTo(copy_name_, 0) | |
score_.CopyTo(copy_score_, 0) | |
Array.Sort(copy_name_, copy_score_) | |
TextBox2.Text &= "名字" & vbTab & "分數" & vbNewLine | |
For o = 0 To 5 | |
TextBox2.Text &= copy_name_(o) & vbTab & copy_score_(o) & vbNewLine | |
Next | |
End Sub | |
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click | |
TextBox2.Clear() | |
name_.CopyTo(copy_name_, 0) | |
score_.CopyTo(copy_score_, 0) | |
Array.Sort(copy_score_, copy_name_) | |
TextBox2.Text &= "名字" & vbTab & "分數" & vbNewLine | |
For o = 0 To 5 | |
TextBox2.Text &= copy_name_(o) & vbTab & copy_score_(o) & vbNewLine | |
Next | |
End Sub | |
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click | |
Dim search As Integer = Array.IndexOf(name_, TextBox3.Text) | |
TextBox4.Text = score_(search) | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment