|
-
Aug 25th, 2003, 08:24 PM
#1
Thread Starter
Hyperactive Member
Could someone tell me what's Wrong With This Code?
Code:
Friend Sub Read_Script_Template()
Dim Handle As Integer
If Len(Dir$(mvarSCRIPT_TEMPLATE_NAME)) = 0 Then
Err.Raise 53 ' File not found
End If
' open in binary mode
Handle = FreeFile
Open mvarSCRIPT_TEMPLATE_NAME$ For Binary As #Handle
' read the string and close the file
SCRIPT_TEMPLATE = Space$(LOF(Handle))
Get #Handle, , SCRIPT_TEMPLATE
Close #Handle
MsgBox SCRIPT_TEMPLATE
End Sub
-
Aug 25th, 2003, 08:32 PM
#2
Well, without knowing what you are expecting, or what you got that you didn't expect, its hard to say.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Aug 25th, 2003, 09:01 PM
#3
Thread Starter
Hyperactive Member
well....
nothing comes up in the message box...
but I don't get any errors or anything....so it finds the file....but it doesn't seem to read it at all...
-
Aug 26th, 2003, 01:59 AM
#4
Frenzied Member
You need to loop through it... I believe......
VB Code:
Do While Not EOF
'Your Code here
Loop
-
Aug 26th, 2003, 02:53 AM
#5
KING BODWAD XXI
shouldnt it be
VB Code:
Get #Handle, 1 , SCRIPT_TEMPLATE
-
Aug 26th, 2003, 03:22 AM
#6
Retired VBF Adm1nistrator
No, his File I/O code is just fine.
I would imagine that perhaps an error is happening, and it is being passed up to the called procedure which has On Error Resume Next in place, or the error is just being ignored.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 26th, 2003, 06:21 AM
#7
Addicted Member
variant/string
Try
Dim SCRIPT_TEMPLATE As String
in your Sub
-
Aug 26th, 2003, 06:22 AM
#8
Retired VBF Adm1nistrator
Re: variant/string
Originally posted by Bregalad
Try
Dim SCRIPT_TEMPLATE As String
in your Sub
It, along with the other variables, could be declared as module level variables - or Option Explicit may not be turned on.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 26th, 2003, 06:32 AM
#9
Addicted Member
Yes, but
Dim SCRIPT_TEMPLATE
or
Dim SCRIPT_TEMPLATE As Variant ' or something else
would cause an error
-
Aug 26th, 2003, 06:35 AM
#10
Retired VBF Adm1nistrator
Ahhh very true. I didn't know the Get keyword wouldn't work with variants. Good call
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 26th, 2003, 06:53 AM
#11
Thread Starter
Hyperactive Member
Yeah....
It is a module level declaration, declared Private as a string...and I am PRETTY sure the option explicit is there (I am at work now, so i can't check)....but i'll look when i get home!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|