代码:
Private Type Word
English As String * 20
Chinese As String * 20
End Type
Private Sub AddWord_Click()
Frame1.Visible = True
List1.Visible = False
End Sub
Private Sub Command1_Click()
Dim Vocabulary As Word
Vocabulary.English = Text1.Text
Vocabulary.Chinese = Text2.Text
Open "C:\Users\Administrator\Desktop\词库.dat" For Random As #1 Len = Len(Vocabulary)
Put #1, LOF(1) / Len(Vocabulary) + 1, Vocabulary
Label3.Caption = "目前词库单词个数:" + CStr(LOF(1) / Len(Vocabulary))
Close #1
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command2_Click()
List1.Clear
Dim Vocabulary As Word
Dim a() As Boolean, n As Integer, RecordID As Integer, k As Integer
Open "C:\Users\Administrator\Desktop\词库.dat" For Random As #1 Len = Len(Vocabulary)
For i = 1 To LOF(1) / Len(Vocabulary)
Get #1, i, Vocabulary
List1.AddItem "(" + CStr(i) + ") " + Trim(Vocabulary.English) + Space(1) + Trim(Vocabulary.Chinese)
Next i
Close #1
List1.Visible = True
End Sub
Private Sub Command3_Click()
List1.Visible = False
End Sub
Private Sub Form_Load()
Frame1.Visible = False
List1.Visible = False
Frame1.Left = 100
Frame1.Top = 100
List1.Left = 100
List1.Top = 100
End Sub
Private Sub Recite_Click()
List1.Clear
Randomize
Frame1.Visible = False
Dim Num As Integer, EnglishWord As String, RightNumber As Integer, VocabularyChinese As String
Num = InputBox("请输入要背诵单词的个数:", "背诵单词", 10)
Dim Vocabulary As Word
Dim a() As Boolean, RecordID As Integer, Counter As Integer
Open "C:\Users\Administrator\Desktop\词库.dat" For Random As #1 Len = Len(Vocabulary)
ReDim a(1 To LOF(1) / Len(Vocabulary))
For i = 1 To LOF(1) / Len(Vocabulary)
a(i) = False
Next i
Do
RecordID = Int(Rnd * (LOF(1) / Len(Vocabulary)) + 1)
If a(RecordID) = False Then
Get #1, RecordID, Vocabulary
For i = 1 To 20
If Mid(Vocabulary.Chinese, i, 1) = " " Then
VocabularyChinese = Left(Vocabulary.Chinese, i - 1)
Exit For
End If
Next i
EnglishWord = InputBox("(" + CStr(Counter + 1) + ")" + Space(1) + Vocabulary.Chinese, "请根据下面出示的中文输入对应的英文单词(共" + CStr(Num) + "个单词)")
If EnglishWord = Trim(Vocabulary.English) Then
RightNumber = RightNumber + 1
List1.AddItem "(" + CStr(Counter + 1) + ")" + Space(1) + VocabularyChinese + Space(1) + "→" + Space(1) + EnglishWord + Space(1) + "√"
Else
List1.AddItem "(" + CStr(Counter + 1) + ")" + Space(1) + VocabularyChinese + Space(1) + "→" + Space(1) + EnglishWord + Space(1) + "×" + Space(1) + Trim(Vocabulary.English)
End If
a(RecordID) = True
Counter = Counter + 1
End If
Loop Until Counter = Num
Label5.Caption = "共默写了" + CStr(Num) + "个单词,其中写对" + CStr(RightNumber) + "个,写错" + CStr(Num - RightNumber) + "个。"
Close #1
List1.Visible = True
End Sub
菜单编辑:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/c75c10385343fbf26c09e86cba7eca8065388f5c?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/6609c93d70cf3bc7a46c83a3db00baa1cd112a14?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
界面设计:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/b999a9014c086e068415760408087bf40bd1cbc4?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
运行界面:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/574e9258d109b3debc43ad27c6bf6c81810a4c84?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/f703738da97739123218cd2ef2198618367ae247?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/faf2b2119313b07e149a1b4706d7912397dd8c5e?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/f2deb48f8c5494eefb2f455627f5e0fe99257e6b?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/6c224f4a20a44623bc31ec2d9222720e0df3d782?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)