Advertisement

07.03.2008 at 11:34AM PDT, ID: 23537794
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Dim A Byte Array In VBA

Asked by hpp123 in Access Coding/Macros, Microsoft Visual Basic.Net, Access Forms

Tags: ,

I am using Access 2003 and was using this code to cut mp3 files into smaller parts:



Private Sub cmdCut_Click()
Dim bytData() As Byte
bytData = ReadFile(App.Path & "\music.mp3", 1, 30000)
Call WriteFile(App.Path & "\1.mp3", bytData)
bytData = ReadFile(App.Path & "\music.mp3", 30001)
Call WriteFile(App.Path & "\2.mp3", bytData)
End Sub

Private Function ReadFile(ByVal strFileName As String, Optional ByVal lngStartPos As Long = 1, Optional ByVal lngFileSize As Long = -1) As Byte()
Dim FilNum As Integer
FilNum = FreeFile
Open strFileName For Binary As #FilNum
If lngFileSize = -1 Then
ReDim ReadFile(LOF(FilNum) - lngStartPos)    <--------------------------------------- Error here
Else
ReDim ReadFile(lngFileSize - 1)
End If
Get #FilNum, lngStartPos, ReadFile
Close #FilNum
End Function

Private Function WriteFile(ByVal strFileName As String, bytData() As Byte, Optional ByVal lngStartPos As Long = -1, Optional ByVal OverWrite As Boolean = True)
Dim FilNum As Integer
FilNum = FreeFile
If OverWrite = True And Dir(strFileName) <> "" Then
Kill strFileName
End If
Open strFileName For Binary As #FilNum
If lngStartPos = -1 Then
Put #FilNum, LOF(FilNum) + 1, bytData
Else
Put #FilNum, lngStartPos, bytData
End If
Close #FilNum
End Function



It worked just fine. Then, I had to reformat the hard drive and put a fresh install of XP Pro. I reinstalled Office 2003 and reinstalled Office 2003 Service Pack 3. Now the code won't work. I get a "Subscript Out of range" error on the first read line (indicated above). It seems to be that the code to Dim a byte array has stopped working. But I don't see why, since it *was* working just fine before.

Can anyone help? What can I do to make this run again?Start Free Trial
 
Loading Advertisement...
 
[+][-]07.03.2008 at 12:22PM PDT, ID: 21928333

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft Visual Basic.Net, Access Forms
Tags: Microsoft, Access 2003 VBA
Sign Up Now!
Solution Provided By: RgGray3
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.03.2008 at 12:25PM PDT, ID: 21928350

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.03.2008 at 01:28PM PDT, ID: 21928755

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628