vb6 to vb.net question

  • Thread starter Thread starter starbuck
  • Start date Start date
S

starbuck

Hi

In VB6 we used the following to get the computer name.

'Computer Name
Dim sBuffer As New String(20)
If GetComputerNameA(sBuffer, 20) <> 0 Then
ComputerName = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1)
End If
If Len(ComputerName) > 10 Then ComputerName = Left(ComputerName, 10)

Can anyone advise an a good alternative in VB.NET as this function no longer
works.

Thanks in advance
 
* "starbuck said:
In VB6 we used the following to get the computer name.

'Computer Name
Dim sBuffer As New String(20)
If GetComputerNameA(sBuffer, 20) <> 0 Then
ComputerName = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1)
End If
If Len(ComputerName) > 10 Then ComputerName = Left(ComputerName, 10)

Can anyone advise an a good alternative in VB.NET as this function no longer
works.

'SystemInformation.ComputerName' or 'Environment.MachineName'.
 
Back
Top