Resolve error message "Only comments can appear after End sub etc.

N

NEWBIE

I keep getting error message "Only comments can appear after End Sub etc..."
when I try to run this script. Would appreciate any help! Am not a VB
programmer.
Was given this script to use.

'//Declare API Function Declarations from Kernel32 DLL
Declare Function GetEnvironmentVariableA Lib "kernel32" ( _
ByVal lpName As String, _
ByVal lpBuffer As String, _
ByVal nsize As Long) As Long

'Returns Client Computer Name by retrieving 32bit environment variable.
Private Function GetClientComputerName() As String

Dim lStringLength As Long 'Len of String
Dim sEnv As String ''' buffer To hold environment string

'Allocate space for Dos Environment String.
sEnv = Space(4096)

'Get data for given environment variable.
lStringLength = GetEnvironmentVariableA("CLIENTNAME", sEnv, 4096)

'Pull value based on lpszenv length.
GetClientComputerName = Left(sEnv, lStringLength)


End Function
 
D

Dirk Goldgar

NEWBIE said:
I keep getting error message "Only comments can appear after End Sub
etc..." when I try to run this script. Would appreciate any help! Am
not a VB programmer.
Was given this script to use.

'//Declare API Function Declarations from Kernel32 DLL
Declare Function GetEnvironmentVariableA Lib "kernel32" ( _
ByVal lpName As String, _
ByVal lpBuffer As String, _
ByVal nsize As Long) As Long

'Returns Client Computer Name by retrieving 32bit environment
variable. Private Function GetClientComputerName() As String

Dim lStringLength As Long 'Len of String
Dim sEnv As String ''' buffer To hold environment string

'Allocate space for Dos Environment String.
sEnv = Space(4096)

'Get data for given environment variable.
lStringLength = GetEnvironmentVariableA("CLIENTNAME", sEnv, 4096)

'Pull value based on lpszenv length.
GetClientComputerName = Left(sEnv, lStringLength)


End Function

There's nothing wrong with the code you posted. Switch the module to
full-module view and look for extraneous statements that don't belong --
for example, executable statements that aren't inside a procedure.
 
Top