hello guys..
i tried this code in my module
and got this error:Code:Public Const sPath As String = Dir("C:\Sample.txt", vbNormal Or vbHidden)
what should i do.?Quote:
Constant Expression Required
thnx in advance..
Printable View
hello guys..
i tried this code in my module
and got this error:Code:Public Const sPath As String = Dir("C:\Sample.txt", vbNormal Or vbHidden)
what should i do.?Quote:
Constant Expression Required
thnx in advance..
You just need to modify it like this.
Code:Public sPath As String
SPath = Dir("C:\Sample.txt", vbNormal Or vbHidden)
as you call it sPath, note the return from dir is filename only
I suspect you are using VB.NET and not VB6. Is that an accurate supposition?
If "c:\sample.txt" file will always be there then you can define your constant like this:
Change scope to Private if you want to declare it in the form.Code:Public Const SAMPLE_FILE As String = "C:\Sample.txt"
Dir("C:\Sample.txt", vbNormal Or vbHidden) will not be constant hence you cannot use it in your constant declaration.
wow.. thank to all of u guys...
@dee-u: thnx for ur reply sir,, ah so it means i cannot use that as a constant?
@westconn1: thnx u sir,, yup i am aware of that..hehehe
@Hack:i am using VB6 sir,,i just trying to make that as constant but i think i cant.
@RhinoBull: nope the "C:\sample.txt" may be there but its hidden, thats why i use Dir to check sir..hehe
@dee-u: thank u sir,, its clear to me now..hehehe