Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/05/2008, 12:32
Avatar de RootK
RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 23 años
Puntos: 50
Re: Object reference not set to an instance of an object.

Intentalo de ésta forma (desde una consola app)

Código:
Module Module1

    Declare Function GetUserName Lib "advapi32.dll" Alias _
       "GetUserNameA" (ByVal lpBuffer As String, _
       ByRef nSize As Integer) As Integer

    Public Function GetUserName() As String
        Dim iReturn As Integer
        Dim userName As String
        userName = New String(CChar(" "), 50)
        iReturn = GetUserName(userName, 50)
        GetUserName = userName.Substring(0, userName.IndexOf(Chr(0)))
    End Function

    Sub Main()

        Console.Write(GetUserName())
        Console.Read()

    End Sub

End Module
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net