|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB 2005 logon formIn 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?
Show quote
On 5 Jul 2006 07:23:40 -0700, "confused" <isabelel***@hotmail.com> It doesn't work because VB2005 uses the .NET Framework.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? Andrew Watt MVP 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 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. -- Show quoteArnie 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 > 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 > > |
|||||||||||||||||||||||