| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:Vb高手帮忙:词表问题
只看楼主 加入收藏
jionjion
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-7-21
收藏
 问题点数:0 回复次数:6 
Vb高手帮忙:词表问题

Option Explicit Dim FileName As String

Private Sub Command1_Click() CommonDialog1.Filter = "文本文档(*.txt)|*.txt" CommonDialog1.ShowOpen FileName = CommonDialog1.FileName Dim ro, cl As Long Dim s, h, t As String ro = 0 cl = 0 MSHFlexGrid1.Rows = Getrows(FileName) MSHFlexGrid1.Cols = Getcols(FileName) Open FileName For Input As #1 While ro <> MSHFlexGrid1.Rows Line Input #1, s If Mid(s, 1, 1) <> "#" Then For cl = 0 To MSHFlexGrid1.Cols - 1 h = Trim(s) t = GetMyWord(h, cl + 1)'点击Command1就说ByRef参数类型不符 If t = "#" Then t = "" MSHFlexGrid1.TextMatrix(ro, cl) = t Next cl ro = ro + 1 End If Wend Close #1 End Sub

Private Function Getrows(filename2 As String) As Integer Dim p, aa As Integer Dim s As String p = 0 On Error GoTo a: b: Open FileName For Input As #1 While Not EOF(1) Line Input #1, s If Mid(s, 1, 1) <> "#" Then p = p + 1 End If Wend Close #1 Getrows = p Exit Function a: aa = MsgBox("没有选取文件", vbYesNo, "提示") If aa = vbYes Then Command1.Value = True GoTo b: End If

End Function

Private Function Getcols(filename2 As String) As Integer Dim p As Integer Dim s As String p = 1 On Error Resume Next Open FileName For Input As #1 Line Input #1, s Close #1 s = Trim(s) Do While InStr(s, " ") <> 0 s = Mid(s, InStr(s, " ")) s = Trim(s) p = p + 1 Loop Getcols = p End Function

Private Function GetMyWord(instring As String, j As Long) As String Dim i As Integer Dim st As String st = " " i = 0 Do While st <> "" instring = Trim(instring) st = Left(instring, InStr(instring, " ")) st = Trim(st) i = i + 1 If st = "" Then GetMyWord = instring Exit Function End If instring = Mid(instring, InStr(instring, " ")) instring = Trim(instring) If i = j Then GetMyWord = st Exit Function End If Loop End Function 到底哪出错了请高手帮忙,谢了。

[此贴子已经被作者于2005-7-31 10:28:30编辑过]

搜索更多相关主题的帖子: 词表 
2005-07-30 22:26
jionjion
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-7-21
收藏
得分:0 
注意我放大的那个“h”,就是提示这里出的问题,对高手来说是很简单的,可对我来说太难了到底错在哪呀?

我是菜鸟中的菜鸟。 QQ:103248112
2005-07-30 22:30
jionjion
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-7-21
收藏
得分:0 
怎么没人帮忙啊

我是菜鸟中的菜鸟。 QQ:103248112
2005-07-31 10:27
Ayuan
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-7-31
收藏
得分:0 
可怜哦

欢迎大家加我!! 虽然我是新手,但是我会努力的!!! 我的QQ:25839115
2005-07-31 10:52
slore
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1108
专家分:0
注 册:2005-7-1
收藏
得分:0 
  on err goto errline
      .............
      ............
     .............
      errline:

试下

快上课了……
2005-08-01 19:35
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
Dim ro, cl As Long           (ro是变体型,cl是Long型,中两者都是Long型,可以这么写)
Dim s, h, t As String  
改成
Dim ro as Long,cl As Long
Dim s As String,h As String,t As String

[此贴子已经被作者于2005-8-2 11:14:06编辑过]



天津网站建设 http://www./
2005-08-02 11:12
jionjion
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-7-21
收藏
得分:0 
行了,多谢版主!原来Vb中不能这样写,这么一个小问题就把我搞的头都大了。

我是菜鸟中的菜鸟。 QQ:103248112
2005-08-03 10:01
快速回复:Vb高手帮忙:词表问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022489 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved