Click here to Skip to main content
16,005,124 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Programically Changing the Color Depth of the monitor Pin
Luc Pattyn21-Jul-07 13:47
sitebuilderLuc Pattyn21-Jul-07 13:47 
QuestionHow to work with multiple dataset tables Pin
HinJinShah21-Jul-07 9:31
HinJinShah21-Jul-07 9:31 
AnswerRe: How to work with multiple dataset tables Pin
Dave Kreskowiak22-Jul-07 4:39
mveDave Kreskowiak22-Jul-07 4:39 
GeneralRe: How to work with multiple dataset tables Pin
HinJinShah22-Jul-07 7:36
HinJinShah22-Jul-07 7:36 
QuestionSave changes to database after loading . Pin
KOKEMO21-Jul-07 4:47
KOKEMO21-Jul-07 4:47 
AnswerRe: Save changes to database after loading . Pin
cutequencher21-Jul-07 6:31
cutequencher21-Jul-07 6:31 
AnswerRe: Save changes to database after loading . Pin
Luc Pattyn21-Jul-07 6:37
sitebuilderLuc Pattyn21-Jul-07 6:37 
QuestionRetrieve Sources() from NTEventlogFiles Pin
jontyler21-Jul-07 4:23
jontyler21-Jul-07 4:23 
I am trying to figure out how to retrieve the Event Sources from an event log using WMI. I am using the list to populate a combobox in the main program. I am including the function that I am using to return a comma-separated list of sources that will be put into an array to add to the combo-box ItemRange property. (I realize there may be a better way to do that part, but I am new to this and any constructive criticism will be appreciated.)

When I run the program, the error is that the Strings.Len(arrSourceNames) must be greater than 0. I can't figure out why the "sources()" property from WMI is not populating.

I have used this code on another function to grab the list of Event Logs (application, system, etc) that are available on the computer (with some modifications, of course). It works in that capacity. I think the problem lies somewhere in pulling the array of sources from the WMI query.

Here is the code...
Private Function GetEventSources(ByVal _computerName As String, ByVal _logFile As String) As String<br />
        Dim arrSourceNames As String = ""<br />
<br />
        If _computerName <> My.Computer.Name.ToString Then<br />
            Dim wmiScope As New ManagementScope("\\" & _computerName & "\root\cimv2")<br />
            wmiScope.Connect()<br />
<br />
            Dim wmiQuery As New ObjectQuery("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName = '" & _logFile & "'")<br />
            Dim searcher As New ManagementObjectSearcher(wmiScope, wmiQuery)<br />
            Dim queryCollection As ManagementObjectCollection = searcher.Get()<br />
            For Each m As ManagementObject In queryCollection<br />
                For Each source As String In m("Sources()")<br />
                    arrSourceNames = arrSourceNames & source & ","<br />
                Next<br />
            Next<br />
        Else<br />
            Dim wmiQuery As New ObjectQuery("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName = '" & _logFile & "'")<br />
            Dim searcher As New ManagementObjectSearcher(wmiQuery)<br />
            Dim queryCollection As ManagementObjectCollection = searcher.Get()<br />
            For Each m As ManagementObject In queryCollection<br />
                For Each source As String In m("Sources()")<br />
                    arrSourceNames = arrSourceNames & source & ","<br />
                Next<br />
            Next<br />
            <br />
        End If<br />
<br />
        Return Strings.Left(arrSourceNames, Strings.Len(arrSourceNames) - 1)<br />
<br />
    End Function


Any help to figure this out will be appreciated greatly.

Jonathan Tyler
AnswerRe: Retrieve Sources() from NTEventlogFiles Pin
Dave Kreskowiak22-Jul-07 4:36
mveDave Kreskowiak22-Jul-07 4:36 
GeneralRe: Retrieve Sources() from NTEventlogFiles Pin
jontyler22-Jul-07 12:58
jontyler22-Jul-07 12:58 
Questionconvert vb.net report to pdf Pin
soniasan21-Jul-07 0:03
soniasan21-Jul-07 0:03 
AnswerRe: convert vb.net report to pdf Pin
Paul Conrad21-Jul-07 5:18
professionalPaul Conrad21-Jul-07 5:18 
Questionmouse button routines in VB6 Pin
farah mazhar20-Jul-07 20:49
farah mazhar20-Jul-07 20:49 
AnswerRe: mouse button routines in VB6 Pin
Dave Kreskowiak22-Jul-07 4:32
mveDave Kreskowiak22-Jul-07 4:32 
QuestionMdi Child Pin
nitin320-Jul-07 19:08
nitin320-Jul-07 19:08 
AnswerRe: Mdi Child Pin
Naji El Kotob20-Jul-07 21:28
Naji El Kotob20-Jul-07 21:28 
GeneralRe: Mdi Child Pin
nitin320-Jul-07 22:38
nitin320-Jul-07 22:38 
AnswerRe: Mdi Child Pin
Naji El Kotob20-Jul-07 22:55
Naji El Kotob20-Jul-07 22:55 
GeneralRe: Mdi Child Pin
nitin320-Jul-07 23:11
nitin320-Jul-07 23:11 
GeneralRe: Mdi Child Pin
Dave Kreskowiak21-Jul-07 5:42
mveDave Kreskowiak21-Jul-07 5:42 
NewsControl Like the Ones Used in the Windows Task Manager Pin
Phoenix9020-Jul-07 18:24
Phoenix9020-Jul-07 18:24 
GeneralRe: Control Like the Ones Used in the Windows Task Manager Pin
Christian Graus20-Jul-07 19:24
protectorChristian Graus20-Jul-07 19:24 
QuestionSystem.IO.FileNotFoundException: Could not load file or assembly 'ADODB, Version=7.0.3300.0, error in vb.net [modified] Pin
babusat20-Jul-07 17:49
babusat20-Jul-07 17:49 
AnswerRe: System.IO.FileNotFoundException: Could not load file or assembly 'ADODB, Version=7.0.3300.0, error in vb.net Pin
Luc Pattyn20-Jul-07 18:26
sitebuilderLuc Pattyn20-Jul-07 18:26 
Question"Value of type 'Double' cannot be converted ... Pin
schmidtjts20-Jul-07 13:51
schmidtjts20-Jul-07 13:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.