pascal java_Pascal、VB、C#、Java四种语法对照表

这段代码实现了文件的导入和导出功能,以及打开和选择数据库的操作。用户可以通过对话框选择是否导出文件到D盘,并指定文件名。同时,代码能读取文本文件内容并显示在richtextbox中,以及打开和选择mdb数据库文件。
摘要由CSDN通过智能技术生成

'///导出文件///

Private Sub Command8_Click()

Dim A As String

A = Text1.Text

Dim n

n = MsgBox("是否导出?", 52, "提示信息")

If n = vbYes Then

Open "D:\\" & A & ".rtf" For Output As #1 '新建文件

Print #1, RichTextBox1.Text

Close #1

MsgBox "文件已经存储在D:\,文件名为" & A & "", 64, "提示信息"

ElseIf n = vbNo Then

MsgBox "操作取消", 64, "提示信息"

Exit Sub

End If

End Sub

'///导入文件///

Private Sub Command9_Click()

Open "D:\给疯狂下资料的朋友们提个醒!.txt" For Input As #1

Dim A

Do While EOF(1) = False

Line Input #1, A

RichTextBox1 = RichTextBox1 & A & vbCrLf                            '这样就好了,要把数据连接起来,否则text只等于最后一行

Loop

Close

End Sub

'///导入文件///

Private Sub mnuOpen_Click()

CommonDialog1.FileName = ""

CommonDialog1.Filter = "*.txt|*.txt|*.rtf|*.rtf|*.*|*.*"

CommonDialog1.DialogTitle = "打开文件"

CommonDialog1.CancelError = True                        '捕获 取消 错误时得先设置为true 然后再showsave

On Error GoTo ErrorHandler

CommonDialog1.ShowOpen

Text1.Text = Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4)

RichTextBox1.LoadFile CommonDialog1.FileName, 1

ErrorHandler:

Exit Sub

End Sub

'///选择数据库///

Private Sub SelData_Click()

CommonDialog1.FileName = ""

CommonDialog1.InitDir = App.Path                        '设置缺省路径

CommonDialog1.Filter = "*.mdb|*.mdb|"

CommonDialog1.DialogTitle = "选择数据库"

CommonDialog1.CancelError = True                        '捕获 取消 错误时得先设置为true 然后再showsave

On Error GoTo ErrorHandler

CommonDialog1.ShowOpen

entry$ = Trim(CommonDialog1.FileName)

dataname = Trim(CommonDialog1.FileName)

R = WritePrivateProfileString("数据库", "库名", entry, iniPath)

If R <> 1 Then MsgBox "写入出错!"

If selectdate = True Then

Combo1(0).Clear

Call Form_Load

Else

Call Main

End If

ErrorHandler:

Exit Sub

End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值