Home All Groups Group Topic Archive Search About
Author
5 Jul 2006 2:23 PM
confused
In vb6 I used the following code:
' Helper object
        Set oNet = CreateObject("WScript.Network")
        ' Get the user name.
        sUser = oNet.UserName
        Select Case txtUserName.Text
            Case 2582
                CurrentUser = "Tester"
            Case Else
                CurrentUser = sUser
         End Select

This code does not work in VB 2005, why not?
What needs to be changed?

Author
5 Jul 2006 2:42 PM
Andrew Watt [MVP]
Show quote
On 5 Jul 2006 07:23:40 -0700, "confused" <isabelel***@hotmail.com>
wrote:

>In vb6 I used the following code:
>' Helper object
>        Set oNet = CreateObject("WScript.Network")
>        ' Get the user name.
>        sUser = oNet.UserName
>        Select Case txtUserName.Text
>            Case 2582
>                CurrentUser = "Tester"
>            Case Else
>                CurrentUser = sUser
>         End Select
>
>This code does not work in VB 2005, why not?
>What needs to be changed?

It doesn't work because VB2005 uses the .NET Framework.

Andrew Watt MVP
Author
5 Jul 2006 2:49 PM
confused
So, on the logon form I want it to grab the users ntlogon, how do I do
this in vb2005?
Andrew Watt [MVP] wrote:
Show quote
> On 5 Jul 2006 07:23:40 -0700, "confused" <isabelel***@hotmail.com>
> wrote:
>
> >In vb6 I used the following code:
> >' Helper object
> >        Set oNet = CreateObject("WScript.Network")
> >        ' Get the user name.
> >        sUser = oNet.UserName
> >        Select Case txtUserName.Text
> >            Case 2582
> >                CurrentUser = "Tester"
> >            Case Else
> >                CurrentUser = sUser
> >         End Select
> >
> >This code does not work in VB 2005, why not?
> >What needs to be changed?
>
> It doesn't work because VB2005 uses the .NET Framework.
>
> Andrew Watt MVP
Author
5 Jul 2006 4:57 PM
Arnie Rowland
This question is better directed to a VB.NET group.

You might look up the use of the Principle object.

With the Principle object you can get the logon users name, groups, etc.

--
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."



Show quote
"confused" <isabelel***@hotmail.com> wrote in message
news:1152110963.521300.129170@l70g2000cwa.googlegroups.com...
> So, on the logon form I want it to grab the users ntlogon, how do I do
> this in vb2005?
> Andrew Watt [MVP] wrote:
>> On 5 Jul 2006 07:23:40 -0700, "confused" <isabelel***@hotmail.com>
>> wrote:
>>
>> >In vb6 I used the following code:
>> >' Helper object
>> >        Set oNet = CreateObject("WScript.Network")
>> >        ' Get the user name.
>> >        sUser = oNet.UserName
>> >        Select Case txtUserName.Text
>> >            Case 2582
>> >                CurrentUser = "Tester"
>> >            Case Else
>> >                CurrentUser = sUser
>> >         End Select
>> >
>> >This code does not work in VB 2005, why not?
>> >What needs to be changed?
>>
>> It doesn't work because VB2005 uses the .NET Framework.
>>
>> Andrew Watt MVP
>
Author
5 Jul 2006 6:55 PM
confused
Resolved problem. Thanks anyhow.
Placed code in form activated works fine.
Dim oNet As Object = CreateObject("WScript.Network")
        Dim sUser As String
       ' Get the user name. On Windows 9x, logged on.
        sUser = oNet.UserName
        Select Case txtUserName.Text
            Case 2582
                CurrentUser = "Test"
            Case Else
                CurrentUser = sUser
        End Select
        txtUserName.Text = CurrentUser


Arnie Rowland wrote:
Show quote
> This question is better directed to a VB.NET group.
>
> You might look up the use of the Principle object.
>
> With the Principle object you can get the logon users name, groups, etc.
>
> --
> Arnie Rowland*
> "To be successful, your heart must accompany your knowledge."
>
>
>
> "confused" <isabelel***@hotmail.com> wrote in message
> news:1152110963.521300.129170@l70g2000cwa.googlegroups.com...
> > So, on the logon form I want it to grab the users ntlogon, how do I do
> > this in vb2005?
> > Andrew Watt [MVP] wrote:
> >> On 5 Jul 2006 07:23:40 -0700, "confused" <isabelel***@hotmail.com>
> >> wrote:
> >>
> >> >In vb6 I used the following code:
> >> >' Helper object
> >> >        Set oNet = CreateObject("WScript.Network")
> >> >        ' Get the user name.
> >> >        sUser = oNet.UserName
> >> >        Select Case txtUserName.Text
> >> >            Case 2582
> >> >                CurrentUser = "Tester"
> >> >            Case Else
> >> >                CurrentUser = sUser
> >> >         End Select
> >> >
> >> >This code does not work in VB 2005, why not?
> >> >What needs to be changed?
> >>
> >> It doesn't work because VB2005 uses the .NET Framework.
> >>
> >> Andrew Watt MVP
> >

AddThis Social Bookmark Button