Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 1st, 2004, 05:45 AM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
End Of Line (EOF) Problem

im having a great problem now..i want to read files like pictures, music...but when i read it like
Code:
Do Until EOF (iRead)
Line Input #iRead, strString
Loop

it reads like half a line and then stops
i have studied the files i read and found out that there is an EOF unicode character that makes the program stop reading it when it hits it. is there any way i can make it read until the real end of line.
thanks in advance

Reply With Quote
  #2  
Old January 1st, 2004, 12:40 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
you're trying to read media files into a string variable?
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old January 1st, 2004, 02:53 PM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
oops, yea ive never thought of that..well how can i read media files into something so i can replace some text in it
you see, i replace each small case letter into a number like (001)(002) means "b"
so i want to do that to pictures and music so i can "encode" them..is there anyway i can do that
thanks in advance

Reply With Quote
  #4  
Old January 1st, 2004, 09:21 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
U should use binary model to read a media file..Because some files are made of binary elements..

This is a simple code:
To write the file, open the file for binary access giving the number of bytes in the array as its record size. Use Put to write the whole array at once.


Private Sub cmdWriteValues_Click()
Dim file_name As String
Dim file_length As Long
Dim fnum As Integer
Dim bytes() As Byte
Dim txt As String
Dim i As Integer
Dim values As Variant
Dim num_values As Integer

' Build the values array.
values = Split(txtValues.Text, vbCrLf)
For i = 0 To UBound(values)
If Len(Trim$(values(i))) > 0 Then
num_values = num_values + 1
ReDim Preserve bytes(1 To num_values)
bytes(num_values) = values(i)
End If
Next i

' Delete any existing file.
file_name = txtFile.Text
On Error Resume Next
Kill file_name
On Error GoTo 0

' Save the file.
fnum = FreeFile
Open file_name For Binary As #fnum Len = num_values
Put #fnum, 1, bytes
Close fnum

' Clear the results.
txtValues.Text = ""
End Sub



To read the file, open the file for binary access its length as its record size. Use Get to read the whole array at once.


Private Sub cmdReadValues_Click()
Dim file_name As String
Dim file_length As Long
Dim fnum As Integer
Dim bytes() As Byte
Dim txt As String
Dim i As Integer

file_name = txtFile.Text
file_length = FileLen(file_name)

fnum = FreeFile
ReDim bytes(1 To file_length)

Open file_name For Binary As #fnum Len = file_length
Get #fnum, 1, bytes
Close fnum

' Display the results.
For i = 1 To file_length
txt = txt & Format$(bytes(i)) & vbCrLf
Next i
txtValues.Text = txt
End Sub

Reply With Quote
  #5  
Old January 1st, 2004, 09:22 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
But if u will display some media file content like music or image,u should use media player control or image control to do it!..

Reply With Quote
  #6  
Old January 2nd, 2004, 05:25 AM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
Unhappy

alright i dont understand anything can u please explain it a piece by piece..since im a begginer in VB6 (ive been using VB.NET)
i dont seem to understand anything from the code
Thanku

Reply With Quote
  #7  
Old January 2nd, 2004, 09:55 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
OK..If u will read a binary file's content..U must read the file from binary format to a byte array which store the content of the all file..
Let's begin at this simple code:

To read the file, open the file for binary access its length as its record size. Use Get to read the whole array at once.


Private Sub cmdReadValues_Click()
Dim file_name As String'file path
Dim file_length As Long'length of the file
Dim fnum As Integer'filehandle number
Dim bytes() As Byte'byte array
Dim txt As String'a string to store the result
Dim i As Integer
'set file_name
file_name = txtFile.Text
'get length of the file
file_length = FileLen(file_name)

'get filehandle for read the file in binary model
fnum = FreeFile
'reset byte array to adapt the file length
ReDim bytes(1 To file_length)
'Open file for binary model
Open file_name For Binary As #fnum Len = file_length
'read the file content to byte array
Get #fnum, 1, bytes
'close filehandle-close the file
Close fnum

' Display the results.
For i = 1 To file_length
'set the each member of byte array to string format,and add it to txt
txt = txt & Format$(bytes(i)) & vbCrLf
Next i
'set the txt to textbox for show the result
txtValues.Text = txt
End Sub

Reply With Quote
  #8  
Old January 2nd, 2004, 04:33 PM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
well cleverpig i dont know we could ever live without u

Reply With Quote
  #9  
Old January 2nd, 2004, 05:18 PM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
when i try to write file in binary it in the underlined line which sais
Code:
    ReDim Preserve bytes(1 To num_values)
 bytes(num_values) = values(i) 
    End If

it tells me a type mismatch error
please help

Reply With Quote
  #10  
Old January 3rd, 2004, 04:38 AM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
Unhappy

haha that was such a silly question...
i waas typing letters instead of binary
___
but i have a greater problem..is there any way i can code a certain picture for example so it cannot be read until it is decoded
so i tryed replaced each "97" with "200" and each "100" with "201"
snd it worked with a text file,,,but when i tryed to do that with a a very small picture (about 8KB) and when writing it came to this underlined line and said a "Overflow"
Code:
    'Make the values array
    Values = Split(TheValues, vbCrLf)
    For I = 0 To UBound(Values)
        If Len(Trim$(Values(I))) > 0 Then
            NumberValues = NumberValues + 1
            ReDim Preserve Bytes(1 To NumberValues)
            Bytes(NumberValues) = Values(I) 
        End If
    Next I

i dont know why it does overflow please help me out i really need to finish this

Reply With Quote
  #11  
Old January 5th, 2004, 01:51 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Yes...This the reason that u won't use certain variable type for 2 variables "bytes and values"..The values is a array that made by a string member,and the bytes is a array that made by a byte member!..when u wanna to assign a byte array member from a string array member,the 2 variables are different by store room in the memory..So the error happened!If u wanna implement this assignment,u will use forced type transfer by CByte() function...

Reply With Quote
  #12  
Old January 5th, 2004, 05:20 AM
Ramihg's Avatar
Ramihg Ramihg is offline
unlink /usr/bin/*
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Vancouver, Canada
Posts: 181 Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level)Ramihg User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 7 h 37 m 27 sec
Reputation Power: 64
ok uve got me all confused up cha know
how do u use this CByte function..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > End Of Line (EOF) Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump