| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1170 人关注过本帖
标题:求助:如何实现保存和打开msflexgrid表格
只看楼主 加入收藏
Yolanda
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2005-3-23
收藏
 问题点数:0 回复次数:3 
求助:如何实现保存和打开msflexgrid表格
如何才能保存msflexgrid表格并且可以方便的打开呢?如果用文本文件需要保存每一个cell的内容吗?请各位大侠帮忙指点迷津啊
搜索更多相关主题的帖子: msflexgrid 表格 保存 
2005-06-23 18:13
jionjion
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-7-21
收藏
得分:0 

我是新手,不知道有没有简单的办法,有的话希望高手告诉我。 我用文本文件来保存和打开。 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 t As String Dim h As String Dim s As String ro = 0 cl = 0 MSHFlexGrid1.Rows = Getrows(FileName) MSHFlexGrid1.Cols = Getcols(FileName) Open FileName For Input As #1 Len = 1000 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) If t = "#" Then t = "" MSHFlexGrid1.TextMatrix(ro, cl) = t Next cl ro = ro + 1 End If Wend Close #1 StatusBar1.Font = "黑体" StatusBar1.SimpleText = "当前词数:" StatusBar1.SimpleText = StatusBar1.SimpleText & CStr(MSHFlexGrid1.Rows - 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 Len = 1000 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 Len = 1000 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

Private Sub Command2_Click() Dim FileName2 As String Dim i, j, dex As Integer CommonDialog1.Filter = "文本文档(*.txt)|*.txt" CommonDialog1.ShowSave FileName2 = CommonDialog1.FileName Open FileName2 For Output As #1 For i = 0 To MSHFlexGrid1.Rows - 1 If i = 1 Then For dex = 1 To 60 Print #1, "#"; Next dex Print #1, End If For j = 0 To MSHFlexGrid1.Cols - 1 If MSHFlexGrid1.TextMatrix(i, j) = "" Or MSHFlexGrid1.TextMatrix(i, j) = " " Then Print #1, "#", Else Print #1, MSHFlexGrid1.TextMatrix(i, j), End If Next j Print #1, Next i Close #1 End Sub


我是菜鸟中的菜鸟。 QQ:103248112
2005-07-31 14:05
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 
存在数据库里不是更方便?

public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2005-08-01 15:16
jasonhe
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2005-5-6
收藏
得分:0 
在哪里可以找到这个msflexgrid表格啊,我在找呢
2005-08-15 19:23
快速回复:求助:如何实现保存和打开msflexgrid表格
数据加载中...
 
   



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

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