vb点虐读取ppt vbs 读取文件
如何用VB.NET增加右键菜单并读取文件(文件夹)地址?
这个简单,我以前用VB6就写过一个类似的程序。 不过这个程序需要提供命令行参数哟。
就算用VB.NET编写,也必须要有接收这个命令行参数的,不然无法实现显示文件或文件夹路径。
下面是注册表文件的内容,你也可以用程序来写入注册表。
*表示所有文件,你可以随便修改。
最后面的%1,表示当前文件或文件夹
REGEDIT4
[HKEY_CLASSES_ROOT\*\shell\显示名称]
[HKEY_CLASSES_ROOT\*\shell\显示名称\command]
@="D:\\绿色软件\\编程\\VB\\显示名称\\显示名称.exe %1"
vb点虐 怎样读取文件
imports System.IO
读取指定文件
'
'读取指定文本文件
Public Function readtext(ByVal path As String)
If path = "" Then
readtext = "操作失败!"
Exit Function
End If
Try
If File.Exists(path) = True Then
Dim fs As New FileStream(path, FileMode.Open)
Dim sr As New StreamReader(fs)
Dim str As String
str = sr.ReadToEnd.ToString
sr.Close()
fs.Close()
readtext = str
Else
readtext = "操作失败!"
End If
Catch ex As Exception
readtext = "操作失败!"
End Try
End Function
'向指定文件写入数据
Public Function writetext(ByVal path As String, ByVal opi As Integer, ByVal msg As String)
If path = "" Then
writetext = "操作失败!"
Exit Function
End If
Dim op As FileMode
Select Case opi
Case 1
op = FileMode.Append
Case 2
op = FileMode.Create
Case Else
op = FileMode.Create
End Select
Try
If File.Exists(path) = True Then
Dim fs As New FileStream(path, op)
Dim sr As New StreamWriter(fs)
sr.WriteLine(msg)
sr.Close()
fs.Close()
writetext = "操作完成!"
Else
writetext = "操作失败!"
End If
Catch ex As Exception
writetext = "操作失败!"
End Try
End Function
vb点虐二进制怎么读取文件?
一、二进制文件读写
1、写二进制数据到指定目录
==将barray字节数组中的数据创建在strFilename目录文件下,存储格式为二进制,False表示不添加,直接覆盖创建。
2、从指定路径下读取二进制数据到数组
==将目录中的文件读取到barry字节数组中,即读取二进制文件。
二、字符文件的读写
1、 将txtFile控件中的字符写到srtFileName指定目录,以创建方式。
2、从srtFileName目录中的文件读取到txtFile控件
VB点虐窗体设计中,如何读取.txt文件中的数据?
1、新建一个标准的VB EXE工程,只有一个Form,Form上有两个按钮:Command1和Command2。
2、双击Command1添加如下代码
Private Sub Command1_Click()
Dim strFile As String
Dim intFile As Integer
Dim strData As String
strFile = "c:\学生成绩.txt"
intFile = FreeFile
Open strFile For Input As intFile
strData = StrConv(InputB(FileLen(strFile), intFile), vbUnicode)
Debug.Print strData
Close intFile
End Sub
3、按F8开始单步调试代码,点击Command1,进入单步调试功能,
4、多次按下F8或直接按下F5运行完成,就完成了读取文本文件内容并输出到立即窗口。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: vb点虐读取ppt vbs 读取文件
本文地址: https://pptw.com/jishu/1032.html