Option Compare Database
Public vThisPCName As String
Public vThisPCNameASCii As String
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If
End Function
Function Convert_ThisPCName()
'Get machine name and assign to variable MyMachineName
vThisPCNameASCii = ""
vThisPCName = fOSMachineName
'Convert Machine name to ASC and save to variable vThisPCNameASCii
Dim i As Integer
Dim LengthOfText As Integer
LengthOfText = Len(vThisPCName)
For i = 1 To LengthOfText
vThisPCNameASCii = vThisPCNameASCii & CStr(Asc(Mid$(vThisPCName, i, 1)))
Next i
End Function