您好,欢迎光临本网站![请登录][注册会员]  
文件名称: vb 小词典下载
  所属分类: .Net
  开发工具:
  文件大小: 308kb
  下载次数: 0
  上传时间: 2013-07-03
  提 供 者: u0112*****
 详细说明: Public Class Form1 Inherits System.Windows.Forms.Form Public Filename As String = "引用英汉词典.txt" '定义连接数据的文本TXT Public Myword(6500, 1) As String '定义二维数组 Public words As Integer = 0 '记录连接数据的文本TXT 单词个数  Private Sub Form1_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim main As String Dim chang As Integer ' 单词长度 Dim i As Integer = 0 '数组的开始位置 Dim n As String '读取相应的单词 Dim m As String '读取单词的中文解释 Dim stringchang As Integer '计算单词后字符串的长度 TextBox1.Text = "" TextBox2.Text = "" FileOpen("英汉小辞典") :|bin:|引用英汉小辞典) '打开文件,相对路径 Do While Not EOF(1) main = LineInput(1) chang = InStr(main, " ") '查找空格的位子。 n = Microsoft.VisualBasic.Left(main, chang - 1) '截取空格字符:单词 Myword(i, 0) = n '保存新的单词 ListBox1.Items.Add(n) stringchang = Len(main) - chang m = Trim(Microsoft.VisualBasic.Right(main, stringchang)) '剩下的字符串赋给变量值m Myword(i, 1) = m '保存中文的翻译(解释) i = i + 1 Loop words = i FileClose(1) End Sub Private Sub ListBox1_SelectedIndexChanged(ByVal sender As 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 Exit Sub End Try 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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim i As Integer = 0 Dim k As Integer Dim EnterWords, ch As String AB: EnterWords = InputBox("请输入想要添加的单词", "添加一个新的单词") '先输入单词 If EnterWords = "" Then MessageBox.Show("必须要输入单词") GoTo AB End If AC: ch = InputBox("需要您输入中文意思", "添加一个新的中文意思") '输入中文意思 If ch = "" Then MessageBox.Show("请输入中文翻译") GoTo AC End If Do While LCase(Myword(i, 0)) < LCase(EnterWords) i = i + 1 If words = i Then '找完数据库再进行添加 Myword(i, 0) = EnterWords '把新添加的单词赋给I位置 Myword(i, 1) = ch '把新添加的单词(中文意思)赋给I的位置 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("词库里已经存在这个单词了") Exit Sub Else 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 '把添加的单词赋给I的位置 Myword(i, 1) = ch '把添加的单词(中文意思)赋给I的位置 words = words + 1 FileOpen(1, Filename, OpenMode.Output) '打开一个文件 For i = 0 To words - 1 PrintLine(1, Myword(i, 0) & " " & Myword(i, 1)) '数组里的单词写入文本文件(TXT) Next FileClose(1) '文件将会关闭 ListBox1.Items.Clear() Form1_load(sender, e) MessageBox.Show("添加成功") Exit Sub End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim ch As String Dim j As Integer If -1 = ListBox1.SelectedIndex Then MsgBox("请选择单词再进行修改") ListBox1.Focus() Exit Sub End If AD: ch = InputBox("请输入修改单词的中文意思", "修改单词", Trim(Myword(ListBox1.SelectedIndex, 1))) If ch = "" Then MessageBox.Show("不能删除以前的中文解释") GoTo AD End If Myword(ListBox1.SelectedIndex, 1) = ch FileOpen(1, Filename, OpenMode.Output) For j = 0 To words - 1 PrintLine(1, Myword(j, 0) & " " & Myword(j, 1)) Next FileClose(1) '文件关闭 ListBox1.Items.Clear() Form1_Load(sender, e) 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 k = MsgBox("您确定是否删除吗?", MsgBoxStyle.YesNo) If 6 = k 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 End Class ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: vb小词典
 输入关键字,在本站1000多万海量源码库中尽情搜索: