• Increase font size
  • Default font size
  • Decrease font size

How to get computer name using Visual Basic 6.0 or VBA?

E-mail Print PDF

The below code use for Visual Basic for Application or Visual Basic 6.0. The function uses to get Computer Name of where this code is running.

Public Function getMachineName() As String
    Dim reVal As String
    reVal = Environ$("computername")
    getMachineName = reVal
End Function