用VB语言制作英汉小辞典

上海应用技术学院课程设计任务书课程名称程序设计基础VB.net课程设计课程代码B704009设计题目英汉小词典题目序号3设计时间2009年6月22日——2009年7月3日... 上海应用技术学院课程设计任务书
课程名称 程序设计基础VB.net课程设计 课程代码 B704009
设计题目 英汉小词典 题目序号 3
设计时间 2009年6月22日——2009年7月3日
系(院) 专业 班级
一、课程设计任务(条件)、具体技术参数(指标)
1.所需知识点:
(1)文本文件读写
(2)字符串处理
(3)数组使用
(4)列表框和组合框控件的使用
2.功能要求:
基本要求:设计如图所示的程序界面,左边列表框中的单词表由读取文件英汉词典.txt得到,选择某单词后,会在上面的文本框中显示相应的内容,并且在右边显示相应的中文解释。具有搜索、增加、修改、删除等功能。若做过增加、修改、删除,应对英汉词典.txt做相应的修改。详情参考样例文件。
拓展要求:在文本框中输入单词时,程序会及时地将已输入的字符开头的所有单词显示在列表框中,供用户浏览;优化搜索算法。
二、对课程设计成果的要求(课程设计报告内容)
1. 用简练、清晰的语言描述课程设计题目的要求和功能。
2. 程序整体结构(模块划分)以及各模块的功能描述。
3. 主要模块的算法(用流程图描述)。
4. 在各模块中,说明使用的变量名及其用途。
5. 程序的界面、交互方式和操作方法的说明。
6. 报告内容完整、层次清晰,绘制图表规范正确。
7. 报告需要交电子版和打印版,源程序交电子版。
展开
 我来答
手机用户d754a
2011-07-04 · TA获得超过4.7万个赞
知道大有可为答主
回答量:3.1万
采纳率:0%
帮助的人:3727万
展开全部
  Public Class Form1
  Inherits System.Windows.Forms.Form
  Public filename As String = "英汉词典.txt"
  Public myword(6500, 1) As String
  Public words As Integer = 0
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim a As String
  Dim b As Integer
  Dim i As Integer = 0
  Dim n As String
  Dim m As String
  Dim stringb As Integer
  TextBox1.Text = ""
  TextBox2.Text = ""
  FileOpen(1, "英汉词典.txt", OpenMode.Input)
  Do While Not EOF(1)
  a = LineInput(1)
  b = InStr(a, " ")
  n = Microsoft.VisualBasic.Left(a, b - 1)
  myword(i, 0) = n
  ListBox1.Items.Add(n)
  stringb = Len(a) - b
  m = Trim(Microsoft.VisualBasic.Right(a, stringb))
  myword(i, 1) = m
  i += 1
  Loop
  words = i
  FileClose(1)

  End Sub
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Dim i As Integer = -1
  If TextBox1.Text = "" Then
  MessageBox.Show("不能输入空格,请重新输入")
  TextBox2.Text = ""
  TextBox1.Focus()
  Exit Sub
  Else
  For i = i + 1 To words
  If LCase(TextBox1.Text) = LCase(myword(i, 0)) Then
  TextBox2.Text = Trim(myword(i, 1))
  Exit Sub
  End If
  Next
  MessageBox.Show(" 您需要的单词不存在,请重新输入")
  End If

  End Sub

  Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
  Try
  TextBox1.Text = myword(ListBox1.SelectedIndex, 0)
  TextBox2.Text = Trim(myword(ListBox1.SelectedIndex, 1))
  Catch ex As Exception

  End Try
  Exit Sub
  End Sub

  Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  Dim ch, enterwords As String
  Dim j, m As Integer
  If -1 = ListBox1.SelectedIndex Then
  MsgBox("请选择单词", , "")
  ListBox1.Focus()
  Exit Sub
  End If
  enterwords = InputBox("请修改单词", "修改单词", Trim(myword(ListBox1.SelectedIndex, 0)))
  Do While enterwords = ""
  m = MsgBox("单词不能为空", MsgBoxStyle.RetryCancel, "修改单词")
  If m = 4 Then
  enterwords = InputBox("请修改单词", "修改单词", Trim(myword(ListBox1.SelectedIndex, 0)))
  Else
  Exit Sub
  End If
  Loop
  ch = InputBox("请修改中文意思", "修改单词", Trim(myword(ListBox1.SelectedIndex, 1)))
  Do While ch = ""
  m = MsgBox("中文意思不能为空", MsgBoxStyle.RetryCancel, "修改单词")
  If m = 4 Then
  ch = InputBox("请修改中文意思", "修改单词", Trim(myword(ListBox1.SelectedIndex, 1)))
  Else
  Exit Sub
  End If
  Loop
  myword(ListBox1.SelectedIndex, 1) = ch
  myword(ListBox1.SelectedIndex, 0) = enterwords
  FileOpen(1, filename, OpenMode.Output)
  For j = 0 To words - 1
  PrintLine(1, myword(j, 0) & " " & myword(j, 1))
  Next
  FileClose(1)
  MsgBox("修改成功")
  ListBox1.Items.Clear()
  Form1_Load(sender, e)

  End Sub

  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  Dim i As Integer = 0
  Dim k, m As Integer
  Dim enterwords, ch As String
  enterwords = InputBox("请输入要添加的单词", "添加单词")
  Do While enterwords = ""
  m = MsgBox("单词不能为空,请输入单词!", MessageBoxButtons.RetryCancel, "添加单词")
  If m = 4 Then
  enterwords = InputBox("请输入要添加的单词", "添加单词")
  Else
  Exit Sub
  End If
  Loop
  ch = InputBox("请输入中文意思", "添加中文")
  Do While ch = ""
  m = MsgBox("中文不能为空,请输入中文意思!", MessageBoxButtons.RetryCancel, "添加中文")
  If m = 4 Then
  ch = InputBox("请输入中文意思", "添加中文")
  Else
  Exit Sub
  End If
  Loop
  Do While LCase(myword(i, 0)) < LCase(enterwords)
  i = i + 1
  If words = i Then
  myword(i, 0) = enterwords
  myword(i, 1) = ch
  words = words + 1
  FileOpen(1, filename, OpenMode.Output)
  For i = 0 To words - 1
  PrintLine(1, myword(i, 0) & " " & myword(i, 1))
  Next
  ListBox1.Items.Clear()
  FileClose(1)
  ListBox1.Items.Clear()
  Form1_Load(sender, e)
  MessageBox.Show("添加成功")
  Exit Sub
  End If
  Loop
  If LCase(myword(i, 0)) = LCase(enterwords) Then
  MessageBox.Show("该单词已存在!")
  ListBox1.SelectedIndex = i
  Exit Sub
  ElseIf LCase(myword(0, 0)) > LCase(enterwords) Then
  For k = words To 0 Step -1
  myword(k + 1, 0) = myword(k, 0)
  myword(k + 1, 1) = myword(k, 1)
  Next
  myword(0, 0) = enterwords
  myword(0, 1) = ch
  words = words + 1
  FileOpen(1, filename, OpenMode.Output)
  For i = 0 To words - 1
  PrintLine(1, myword(i, 0) & " " & myword(i, 1))
  Next
  ListBox1.Items.Clear()
  FileClose(1)
  Form1_Load(sender, e)
  MessageBox.Show("添加成功")
  Exit Sub
  End If
  For k = words To i + 1 Step -1
  myword(k + 1, 0) = myword(k, 0)
  myword(k + 1, 1) = myword(k, 1)
  Next k
  myword(i, 0) = enterwords
  myword(i, 1) = ch
  words = words + 1
  FileOpen(1, filename, OpenMode.Output)
  For i = 0 To words - 1
  PrintLine(1, myword(i, 0) & " " & myword(i, 1))
  Next
  FileClose(1)
  ListBox1.Items.Clear()
  Form1_Load(sender, e)
  MessageBox.Show("添加成功")
  Exit Sub

  End Sub

  Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  Dim i, j, k As Integer
  If -1 = ListBox1.SelectedIndex Then
  MsgBox("请选择单词", , "")
  ListBox1.Focus()
  Exit Sub
  End If
  k = MsgBox("确定是否删除", MsgBoxStyle.YesNo, "提示")
  If k = 6 Then
  For i = ListBox1.SelectedIndex To words
  myword(i, 0) = myword(i + 1, 0)
  myword(i, 1) = myword(i + 1, 1)
  Next
  words = words - 1
  FileOpen(1, filename, OpenMode.Output)
  For j = 0 To words - 1
  PrintLine(1, myword(j, 0) & " " & myword(j, 1))
  Next
  FileClose(1)
  MsgBox("单词已删除")
  ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
  ListBox1.Refresh()
  TextBox1.Text = ""
  TextBox2.Text = ""
  Exit Sub
  Else
  Exit Sub
  End If
  End Sub

  Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  TextBox1.Text = ""
  TextBox2.Text = ""
  End Sub
  End Class
  这是代码,文字性的内容自己去做。
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式