问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

VB 如何去掉文件头部指定的字节数

发布网友 发布时间:2022-12-25 23:42

我来回答

2个回答

热心网友 时间:2023-07-02 15:12

新建并打开一个文件夹,在新建的文件夹里创建两个 文本文档 文件,分别粘贴保存指定内容,并按要求命名文件。最后双击“工程1.vbp”这个文件即可!
第一个粘贴以下内容(不要等号分隔线),保存,并命名为 工程1.vbp
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation
Form=Form1.frm
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCX
Startup="Form1"
HelpFile=""
Command32=""
Name="工程1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="FREE"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1

[MS Transaction Server]
AutoRefresh=1
======================================
第二个粘贴以下内容(不要等号分隔线),保存并命名为 Form1.frm
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
BorderStyle = 4 'Fixed ToolWindow
Caption = "Form1"
ClientHeight = 3120
ClientLeft = 45
ClientTop = 360
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4680
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.OptionButton Option2
Caption = "擦除"
Height = 375
Left = 1440
TabIndex = 9
Top = 1800
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "剪掉"
Height = 375
Left = 0
TabIndex = 8
Top = 1800
Value = -1 'True
Width = 1215
End
Begin MSComDlg.CommonDialog CDL
Left = 2880
Top = 2160
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command3
Caption = "打开文件"
Height = 615
Left = 2880
TabIndex = 7
Top = 0
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 615
Left = 2880
TabIndex = 5
Top = 1440
Width = 1695
End
Begin VB.CommandButton Command1
Caption = "执行"
Height = 615
Left = 2880
TabIndex = 4
Top = 720
Width = 1695
End
Begin VB.TextBox Text2
Height = 375
Left = 0
TabIndex = 3
Text = "0"
Top = 1080
Width = 2775
End
Begin VB.TextBox Text1
Height = 375
Left = 0
TabIndex = 2
Text = "0"
Top = 360
Width = 2775
End
Begin VB.Label Label4
Caption = "去除方式:"
Height = 495
Left = 0
TabIndex = 10
Top = 1560
Width = 2775
End
Begin VB.Label Label3
BorderStyle = 1 'Fixed Single
Caption = "准备就绪"
Height = 375
Left = 0
TabIndex = 6
Top = 2760
Width = 4695
End
Begin VB.Label Label2
Caption = "去除的字节数:"
Height = 495
Left = 0
TabIndex = 1
Top = 840
Width = 2775
End
Begin VB.Label Label1
Caption = "从第几个字节开始去除:"
Height = 375
Left = 0
TabIndex = 0
Top = 120
Width = 2655
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Doing As Boolean '是否正在处理
Private FName As String '将要处理的文件名及路径

Private Sub Command1_Click()
Dim FNum As Long, Fnum2 As Long
Dim FLen As Long
Dim Dat() As Byte
Dim PathGet() As Byte
Dim NewFile As String
Dim ChukLen As Long
Dim Start As Long
Dim Cuts As Long
Dim i As Long, j As Long, Abyte As Byte
Start = Val(Text1)
Cuts = Val(Text2)
If Start < 1 Or Cuts < 1 Or FName = "" Then Exit Sub
Command3.Enabled = False
Command1.Enabled = False
PathGet = StrConv(FName, vbFromUnicode)
FNum = UBound(PathGet)
For i = UBound(PathGet) To 0 Step -1
If PathGet(i) = Asc("\") Then
ReDim Preserve PathGet(0 To UBound(PathGet) + 4)
For j = 0 To FNum - i
PathGet(UBound(PathGet) - j) = PathGet(FNum - j)
Next
PathGet(i + 1) = Asc("P")
PathGet(i + 2) = Asc("i")
PathGet(i + 3) = Asc("k")
PathGet(i + 4) = Asc("_")
NewFile = StrConv(PathGet, vbUnicode)
MsgBox "新的文件为:" & vbNewLine & NewFile
Exit For
End If
Next
FNum = FreeFile

Open FName For Binary As FNum
FLen = LOF(FNum)
If Start + Cuts > FLen Then
MsgBox "超出文件尾!"
Close FNum
Exit Sub
End If
Fnum2 = FreeFile
Open NewFile For Binary As Fnum2
Start = Start - 1
Doing = True
i = Start
Do While i > 0
If i <= 1024 Then
ReDim Dat(i - 1)
Get FNum, , Dat
Put Fnum2, , Dat
ChukLen = ChukLen + i
i = 0
Label3 = Int(ChukLen / FLen * 100) & "%"
If Doing Then GoTo Last
DoEvents
Else
ReDim Dat(1023)
Get FNum, , Dat
Put Fnum2, , Dat
i = i - 1024
ChukLen = ChukLen + 1024
Label3 = Int(ChukLen / FLen * 100) & "%"
If Doing Then GoTo Last
DoEvents
End If
Loop
If Option2 Then
i = Cuts
Do While i > 0
If i <= 1024 Then
ReDim Dat(i - 1)
Put Fnum2, , Dat
i = 0
ChukLen = ChukLen + i
Label3 = Int(ChukLen / FLen * 100) & "%"
If Doing Then GoTo Last
DoEvents
Else
ReDim Dat(1023)
Put Fnum2, , Dat
i = i - 1024
ChukLen = ChukLen + 1024
Label3 = Int(ChukLen / FLen * 100) & "%"
If Doing Then GoTo Last
DoEvents
End If
Loop

End If
Get FNum, Start + Cuts, Abyte
i = FLen - Start - Cuts
Do While i > 0
If i <= 1024 Then
ReDim Dat(i - 1)
Get FNum, , Dat
Put Fnum2, , Dat
i = 0
ChukLen = ChukLen + i
Label3 = Int(ChukLen / FLen * 100) & "%"
If Doing Then GoTo Last
DoEvents
Else
ReDim Dat(1023)
Get FNum, , Dat
Put Fnum2, , Dat
i = i - 1024
ChukLen = ChukLen + 1024
Label3 = Int(ChukLen / FLen * 100) & "%"
If Doing Then GoTo Last
DoEvents
End If
Loop
Close FNum
Close Fnum2
Doing = False
Command1.Enabled = True
Exit Sub
Last:
Close FNum
Close Fnum2
Doing = False
Command1.Enabled = True
On Error Resume Next
Kill NewFile
End Sub

Private Sub Command2_Click()
Command3.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Doing = True
End Sub

Private Sub Command3_Click()
CDL.CancelError = False
CDL.ShowOpen
If CDL.FileName = "" Then Exit Sub
FName = CDL.FileName
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = False
Doing = False
End Sub

Private Sub Form_Load()
Doing = False
Command1.Enabled = False
Command2.Enabled = False

End Sub

=================================================

热心网友 时间:2023-07-02 15:13

用 SEEK=...来解决 再接着读取就是了
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
14岁每天做多少蹲起和提踵不影响长高 每天晚上提踵来练弹跳会影响长高吗? 提踵和练肌肉会不会长不高? 提踵(抬脚跟)训练会影响长个吗 求高人指点 提踵 会不会影响身高的增长? 我现在15岁 提踵有利于长高吗 提踵影响长高吗 win10可不可以玩盗版的中2,帝战,拿战 沧州蓝海光伏设备有限公司怎么样? 为什麽女巫要骑扫帚不骑板凳。。。 CPU帮我看看什么意思 各位大虾,帮我看看下面的配置能超频不,能超到好几?CPU,MAINBOARD都想超一下,希望给点指点..谢谢 已经不用了,绑定的银行卡如何消除 以前微信绑定银行卡,以前的不用了,请问怎么才能解除绑定? 2019版奇瑞eQ1和受人追捧的欧拉R1两个哪个更让人看好? 什么是声卡一体机 幼儿园微信群可以发哪些信息 怎么去身上的静电 哪些书适合信息处理技术员 好物推荐!性价比高的四款电热蚊香液。 电热蚊香液哪个牌子好? 电热蚊香液什么牌子好 2021年初级会计职称考试科目特点及难易分析 一建考试试卷忘写名字答题卡写了,影响成绩吗 2022年一建泄题了吗 为什么酷家乐效果图自己自己设置的音乐在电脑上有声音在手机上没 如果汤或者饭做得太干了可以加水再煮一下吗?这样对胃好不?求解 请问教师资格证报名居住证选是还是否 迈腾感应门把手失灵是什么原因? 个人观点:鳌拜是个怎样的人物 忘记了怎么注销微信绑定的银行卡? 我以前的上不去了,我想把绑定的银行卡取消了,怎么弄啊? MCITP认证证书在哪考 怎样考医疗资格证书 简单的绕口令 幼儿园 儿童 绕口令短句 华为手机两个如何同时登录 华为怎么登录两个码 读研建议去国防科技大学吗 兄弟牌的复印机可否使用其他牌子的墨粉 如何在微信群中查看对方的? 录像用英语怎么说词组 松根干了还能腌菜吗 于和伟洗脚007是什么电视剧 淘宝买的iphone能去售后换机么 从淘宝买的手机出现了问题怎么维修 苹果6在淘宝上买的 可以保修吗 没有发票 我在淘宝上买了一部iphone4,现在手机出现了问题,拿去售后维修保险吗 儿童英语单词怎么读如何英语表达儿童 172.17.211.81是哪类ip地址