Get VB net code to work

  • Thread starter Thread starter Maarkr
  • Start date Start date
M

Maarkr

tried to run some code from VBnet in Access, and these functions they declare
give an error in Access cause there's no End Function to them... is there a
way to run them?

Private Declare Function DoFileDownload Lib "shdocvw" _
(ByVal lpszFile As String) As Long


Private Sub Command1_Click()

Dim sDownload As String

sDownload = StrConv(Text1.Text, vbUnicode)
Call DoFileDownload(sDownload)

End Sub
 
hi,
tried to run some code from VBnet in Access, and these functions they declare
give an error in Access cause there's no End Function to them...
No, that's not the cause.
is there a way to run them?
sDownload = StrConv(Text1.Text, vbUnicode)
You can only use .Text when the according control has the focus. This is
not the case, as this is executed in the command click event.

Use .Value instead of .Text:

sDownload = StrConv(Text1.Value, vbUnicode)



mfG
--> stefan <--
 
By "VBnet", I assume you're talking about Randy Birch's VBNet site, because
that's definitely not .Net code!

That code should work fine in VBA. What's the exact error message you're
getting, and what line of code raises the error?
 
Stefan Hoffmann said:
You can only use .Text when the according control has the focus. This is
not the case, as this is executed in the command click event.

Use .Value instead of .Text:

Good eyes, Stefan. I missed that.
 
Yes, it is from Birch's VB net site... the error is:

Compile error

Only comments may appear after End Function, End Sub...

The 'Private Declare Function...' line is highlighted, and there is no End
Function portion of the code...I added it and it didn't work...I also tried
to move it to a module but no good there either. There was another function
 
Where have you placed that "Private Declare Function..." declaration?

It must be at the top of the module, before any of your own code.
 
that was it! thanks

Douglas J. Steele said:
Where have you placed that "Private Declare Function..." declaration?

It must be at the top of the module, before any of your own code.
 
You can only use .Text when the according control has the focus.
This is not the case, as this is executed in the command click
event.

Use .Value instead of .Text:

sDownload = StrConv(Text1.Value, vbUnicode)

Or use nothing at all, since .Value is the default property of
controls on Access forms.
 
Back
Top