易截截图软件、单文件、免安装、纯绿色、仅160KB

重拾VB之三,二进制文件篇

重拾VB之三,二进制文件篇
PMP 关劲松
     鬼使神差,09年12月入职的公司仍使用VB开发软件,虽然并非专职开发,但也不得不在事隔4年之后,重新使用VB。
读取、修改二进制文件仍是大部分编程语言的基本开发技能。可以提高处理文件效率,主要应用在通信、交换数据等方面。
'open   filename$   for   binary   #filenumber'以二进制方式建立或者打开文件,然后再用
  'Put #FileNumber, postion, inputdata '写入数据inputdata,
  'Get #FileNumber, postion, outputdata '读出数据到outputvarible
#FileNumber, 打开的二进制文件流。
 postion,    文件中的数据位置。
 inputdata   输入数据缓冲。可以使用数组或字符串。
 outputdata  输出数据缓冲。可以使用数组或字符串。
代码
 
Sub read()
Dim strFileName1, s As String
Dim aryContent(20) As Byte
strFileName1 = App.Path & "\test.hex"
Open strFileName1 For Binary As 1
Get #1, 120, aryContent() '从文件中120字节处取出长度20的数据到数组中。
msgbox(aryContent())      '以16进制的方式显示。
s = Space(20)     '重定义字符串长度。
Get #1, 2514, s   ' 从文件中120字节处取出长度20的数据到字符串中。
msgbox(s)         '以字符的方式显示。
Close 1
End Sub
Sub write()
Dim strFileName1, s As String
Dim aryContent(20) As Byte
strFileName1 = App.Path & "\test.hex"
Open strFileName1 For Binary As 1
s = Space(20)
s = "teststtsestssts33333"
 
Put #1, 2486, s         '在文件中2486字节处写入长度20的字符串数据。
Debug.Print s
aryContent(0) = &H4F    '初始化数组
aryContent(1) = &H33
aryContent(2) = &HA1
aryContent(3) = &H42
aryContent(4) = &H8D
Put #1, 2514, aryContent()      ''在文件中2514字节处写入长度20的十六进制数组数据。
Debug.Print aryContent()
Close 1
End Sub


相关文档:

vb Active 控件 集合类 问题

引言:
         做一个控件, 用于 数据采样如示波器, 可以添加,删除曲线, 设置曲线的相关属性: 线型,颜色,等...
过程:
         先创建 线 类,  在用户控件里实现 线 对象创建,  并声明一个 集合, 用于 存放建立的线对象.
问题 ......

VB 取得指定exe文件版本号

【函数】  
  GetFileVersionInfo  
   
  【操作系统】  
  Win9X:Yes  
  WinNT:Yes  
   
  【声明】  
  GetFileVersionInfo   Lib   "version.dll"     Alias   "GetFileVersionInfoA" &n ......

“自动点击按钮”小工具VB源码

“自动点击按钮”小工具VB源码
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Pri ......

VB对INI文件操作

VB对INI文件操作
2009-02-25 00:17
INI 文件是什么样子?——不会吧,这都不知道。INI 文件就是 Windows 中常见
的以 .ini 为扩展名的文件,其内部格式和各部分的名称如下:
[Section1]
Key1=Value1
Key2=Value2
Key3=Vlaue3
[Section2]
Key1=Value1
Key2=Value5
Key4=Value4
Key5=...
...
 & ......

VB.NET中能不能对DATASET再用SQL语言

可以筛选数据,但不能是标准的SQL语句:
Me.DsUserManager1.Tables(0).Select("id > 5 and id <20")
---------------------------------------------------------------
1.筛选:
dataset.tables("tabname").select("id=1")'相当于SQL中WHERE后的条件内容
2.保存到哪?这倒是不知 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号