INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: vb.net woes  (Read 1858 times)

llafriel

  • World Citizen
  • ***
  • Posts: 230
vb.net woes
« on: October 14, 2009, 11:32:38 am »

Hello again.

I want to search MC' database and present the result in a listbox. The search works fine, but getting the result into a listbox gives me errors. The code below sort of works but it fills the listbox with 'System.__comObject' for every searchhit.

        Dim list As MediaCenter.IMJFilesAutomation
        Dim antall, teller As Integer
        search = "[Video Type]=[Film]"
        list = mediaCenterRef.Search(search)
        antall = list.GetNumberFiles()
        TextBox1.Text = antall
        For teller = 0 To antall
            ListBox1.Items.Add(list)
        Next
Logged

gappie

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 4565
Re: vb.net woes
« Reply #1 on: October 14, 2009, 12:45:10 pm »

i guess you want the names filling that listbox? i would add the next item to the script, i can be wrong, did not test it.

first i would use:
For teller = 0 To antall -1

then you should get the name from the list:

Dim listitem As MediaCenter.IMJFileAutomation
Dim MName as string
listitem = list.GetFile(teller)
MName=Listitem.Get("Name", False)

and use that in :
ListBox1.Items.Add(MName)

the result could be something like:

Dim list As MediaCenter.IMJFilesAutomation
Dim listitem As MediaCenter.IMJFileAutomation
Dim MName as string
Dim antall, teller As Integer

        search = "[Video Type]=[Film]"
        list = mediaCenterRef.Search(search)
        antall = list.GetNumberFiles()
        TextBox1.Text = antall
        For teller = 0 To antall - 1
      listitem = list.GetFile(teller)
      MName=Listitem.Get("Name", False)
               ListBox1.Items.Add(MName)
        Next

hope it gives some ideas.

 :)
gab
Logged

pbair

  • Recent member
  • *
  • Posts: 33
Re: vb.net woes
« Reply #2 on: October 14, 2009, 01:11:33 pm »

Hello again.

I want to search MC' database and present the result in a listbox. The search works fine, but getting the result into a listbox gives me errors. The code below sort of works but it fills the listbox with 'System.__comObject' for every searchhit.

        Dim list As MediaCenter.IMJFilesAutomation
        Dim antall, teller As Integer
        search = "[Video Type]=[Film]"
        list = mediaCenterRef.Search(search)
        antall = list.GetNumberFiles()
        TextBox1.Text = antall
        For teller = 0 To antall
            ListBox1.Items.Add(list)
        Next

I just did a very similar thing earlier today.  I added the filenames from an MC db search to a List object.  I think the changes shown in red below will fill your listbox.  You can replace "Name" with whatever database field you need.

        Dim list As MediaCenter.IMJFilesAutomation
        Dim antall, teller As Integer
        search = "[Video Type]=[Film]"
        list = mediaCenterRef.Search(search)
        antall = list.GetNumberFiles()
        TextBox1.Text = antall
        For teller = 0 To antall-1
            ListBox1.Items.Add(list.Get(teller,"Name").Tostring)
        Next
Logged

llafriel

  • World Citizen
  • ***
  • Posts: 230
Re: vb.net woes
« Reply #3 on: October 14, 2009, 02:13:20 pm »

Great stuff guys, just what i needed. Thanks!  :)
Logged
Pages: [1]   Go Up