New topic: Load strings into Listbox Column
<http://forums.realsoftware.com/viewtopic.php?t=46605> Page 1 of 1 [ 6 posts ] Previous topic | Next topic Author Message p0wn3d Post subject: Load strings into Listbox ColumnPosted: Fri Jan 18, 2013 8:09 am Joined: Sun Oct 28, 2012 4:54 am Posts: 92 Location: Herts, UK Hello again I have a 2 column listbox in my application. I am using the following code to read the the shell output string into the first column. dim s As new Shell, Result as String dim servicename as string dim status as string s.Execute "wmic service get name" Result=s.ReadAll servicename= ReplaceAll(Result, Chr(&h0D) + Chr(&h0D), Chr(&h0D)).Trim dim lin() as string = Split( ReplaceLineEndings(servicename, EndOfLine), EndOfLine ) for each X as String in lin Listbox1.addrow X next The end result is: I need to execute as second shell command s.Execute "wmic service get state" and somehow populate the 2nd column with the returned output string. Can anyone please help with this Thanks _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top DaveS Post subject: Re: Load strings into Listbox ColumnPosted: Fri Jan 18, 2013 9:30 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4441 Location: San Diego, CA for each X as String in lin Listbox1.addrow X s.execute "wmic service get state" listbox1.cell(listbox1.lastindex,1)=s.result next make sure of course the the shell command completed before moving on.. but you get the idea. _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top p0wn3d Post subject: Re: Load strings into Listbox ColumnPosted: Fri Jan 18, 2013 9:37 am Joined: Sun Oct 28, 2012 4:54 am Posts: 92 Location: Herts, UK Thank you Dave really gratefull _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top ktekinay Post subject: Re: Load strings into Listbox ColumnPosted: Fri Jan 18, 2013 9:40 am Joined: Mon Feb 05, 2007 5:21 pm Posts: 374 Location: New York, NY Just remember that the order of the array is not guaranteed with For Each. If the order matters, use: for i as integer = 0 to lin.Ubound dim X as string = lin( i ) ... next _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top p0wn3d Post subject: Re: Load strings into Listbox ColumnPosted: Fri Jan 18, 2013 9:42 am Joined: Sun Oct 28, 2012 4:54 am Posts: 92 Location: Herts, UK Ah yes thanks for pointing that out Kem _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top p0wn3d Post subject: Re: Load strings into Listbox ColumnPosted: Fri Jan 18, 2013 10:10 am Joined: Sun Oct 28, 2012 4:54 am Posts: 92 Location: Herts, UK Thanks Guys got it all working in the end with this: dim s As new Shell, Result, servicename, status as String s.Execute "wmic service get name" Result=s.ReadAll servicename= ReplaceAll(Result, Chr(&h0D) + Chr(&h0D), Chr(&h0D)).Trim dim lin() as string = Split( ReplaceLineEndings(servicename, EndOfLine), EndOfLine ) s.Execute "wmic service get state" Result=s.ReadAll status= ReplaceAll(Result, Chr(&h0D) + Chr(&h0D), Chr(&h0D)).Trim dim lin2() as string = Split( ReplaceLineEndings(status, EndOfLine), EndOfLine ) for i as integer = 0 to lin.Ubound dim y as string = lin(i) dim X as string = lin2( i ) Listbox1.addrow y listbox1.cell(listbox1.lastindex,1)=X next Normally I would just use a plugin for doing WMI related queries and yes absolutely nothing wrong with using plugins it's just that IMO they don't allow you to get under the bonnet and learn more. _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 6 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml rbforumnotifier@monkeybreadsoftware.de