Private Sub CmdT_Click()
Dim j As Long
If TxtT.Text <> "" And Txt4.Text <> "" Then '如果都不为空,且不存在则添加
For i = 0 To UBound(Myword)
If LCase(TxtT.Text) <> LCase(Myword(i)) Then
Open App.Path & "\data\eng.xcd" For Append As #1
Print #1, TxtT.Text + " " + Txt4.Text
Close #1
ReDim Preserve Myword(UBound(Myword) + 1)
ReDim Preserve Myexplan(UBound(Myexplan) + 1)
Myword(UBound(Myword)) = TxtT.Text
Myexplan(UBound(Myexplan)) = Txt4.Text
MsgBox "添加完成", , "完成"
Else '如果存在所添加的关键词,则用msgbox 是否替换,是替换
Dim Msg, Style, Title, Help, Ctxt, Response
Msg = "关键词已存在,是否要替换关键词?"
Style = vbYesNo + vbDefaultButton2
Title = "MsgBox Demonstration"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
Myword(i) = TxtT.Text
Myexplan(i) = Txt4.Text
Open App.Path & "\data\eng.xcd" For Output As #3
For j = 0 To UBound(Myword)
Print #3, Myword(j) & "" & Myexplan(j)
Next j
Close #3
End If
End If
Next i
Else: MsgBox "请输入关键词或解释" '有一个为空则提示
End If
End Sub
这好是一个添加关键词和注释的代码,在txtT中输入关键词,在txt4中输入注释,不过这个在msgbox处有问题,不知道怎么解决,后面的替换处不知道对不对
Dim j As Long
If TxtT.Text <> "" And Txt4.Text <> "" Then '如果都不为空,且不存在则添加
For i = 0 To UBound(Myword)
If LCase(TxtT.Text) <> LCase(Myword(i)) Then
Open App.Path & "\data\eng.xcd" For Append As #1
Print #1, TxtT.Text + " " + Txt4.Text
Close #1
ReDim Preserve Myword(UBound(Myword) + 1)
ReDim Preserve Myexplan(UBound(Myexplan) + 1)
Myword(UBound(Myword)) = TxtT.Text
Myexplan(UBound(Myexplan)) = Txt4.Text
MsgBox "添加完成", , "完成"
Else '如果存在所添加的关键词,则用msgbox 是否替换,是替换
Dim Msg, Style, Title, Help, Ctxt, Response
Msg = "关键词已存在,是否要替换关键词?"
Style = vbYesNo + vbDefaultButton2
Title = "MsgBox Demonstration"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
Myword(i) = TxtT.Text
Myexplan(i) = Txt4.Text
Open App.Path & "\data\eng.xcd" For Output As #3
For j = 0 To UBound(Myword)
Print #3, Myword(j) & "" & Myexplan(j)
Next j
Close #3
End If
End If
Next i
Else: MsgBox "请输入关键词或解释" '有一个为空则提示
End If
End Sub
这好是一个添加关键词和注释的代码,在txtT中输入关键词,在txt4中输入注释,不过这个在msgbox处有问题,不知道怎么解决,后面的替换处不知道对不对
