Showing results 1 to 6 of 6

Thread: Get All User Name

  1. #1
    Join Date
    27.07.2015
    Posts
    9

    Default Get All User Name

    Hello,

    I want to get all the user names present in my project in listbox at runtime using VB.Net VSTA.

  2. #2
    Join Date
    20.08.2009
    Posts
    293

    Default Re: Get All User Name

    Hi,

    what exactly do you want to do with the list/how do you want to display it?

    With this code you would get the users as a list of strings:

    Public Sub Macro_GetUsers()
       Dim userList As New List(Of String)
       For i = 0 To Me.Passwords.CountUser - 1
          userList.Add(Me.Passwords.ItemUser(i).Name)
       Next
    End Sub

    For displaying them in a listbox you can create a string like this in VSTA which can be written to a zenon string variable which is the "display source" for a combo/listbox in zenon, see manual:
    Manual -> Screens -> Screen elements -> Combo/List Box
    -> Dynamic combobox or list box

    '...
    Dim userListAsString As String
    userListAsString = String.Empty
    
    For i = 0 To Me.Passwords.CountUser - 1
    userListAsString = userListAsString + i.ToString() + "," +   Me.Passwords.ItemUser(i).Name + ";"
    Next
    
    Me.Variables.Item("userListVariable").set_Value(0, userListAsString)
    '...


    Regards,
    Bernhard

  3. #3
    Join Date
    27.07.2015
    Posts
    9

    Default Re: Get All User Name

    Thanks for the quick reply.I want to create windows form in VSTA in which it will list all the user names and that form should get run on zenon button click event.

  4. #4
    Join Date
    20.08.2009
    Posts
    293

    Default Re: Get All User Name

    Hi,

    well then you can simply create a form in VSTA with a listbox containing the string array from my last post.

    To show this form create a VSTA Macro execute function linked to a button in zenon where you execute the VSTA macro which opens form and fills the listbox with the data from.

    Regards,
    Bernhard

  5. #5
    Join Date
    27.07.2015
    Posts
    9

    Default Re: Get All User Name

    I am able to create Form and show on button Click Event but Me.Passwords.CountUser and Me.Passwords.ItemUser(i).Name is resulting into error.
    Last edited by jwick8801 : 19th August 2015 at 07:07

  6. #6
    Join Date
    20.08.2009
    Posts
    293

    Default Re: Get All User Name

    Hi,

    see code below (just to give an idea as VB.NET is not really my programming language):

    ThisProject.vb code:
    Public Sub Macro_GetUsers()
    
       Dim userList As New List(Of String)
    
       For i = 0 To Me.Passwords.CountUser - 1
          userList.Add(Me.Passwords.ItemUser(i).Name)
       Next
    
       Dim myForm As New Form1(userList)
    
       myForm.Show()
    
    End Sub

    Form1.vb code (Form1 contains a Listbox named ListBox1):
    Public Class Form1
    
       Public Sub New(ByVal userList As List(Of String))
    
          InitializeComponent()
    
          For i = 0 To userList.Count - 1
             ListBox1.Items.Add(userList.Item(i))
          Next
    
      End Sub
    
    End Class

    If you are planning to do more with VSTA, a training would be highly recommended.

    Regards,
    Bernhard

Similar Threads

  1. User Verwaltung in C#
    By armins in forum VSTA
    Replies: 5
    Last Post: 18th March 2014, 03:30
  2. User Control
    By navaneet in forum zenon Supervisor
    Replies: 4
    Last Post: 8th October 2013, 04:26
  3. User in subprojects
    By n.bulgarini in forum VBA
    Replies: 4
    Last Post: 1st June 2011, 09:17
  4. ActiveDirectory User
    By maxh in forum VBA
    Replies: 1
    Last Post: 3rd February 2011, 00:28
  5. How to evaluate the user level a user has in the runtime?
    By markclemens in forum zenon Supervisor
    Replies: 0
    Last Post: 6th November 2007, 17:10

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •