473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Using ComboBoxList Selected Item as a Variable

Hi have searched and searched but cannot find a specific answer to this..

I have a form with a combobox with a list of PC names.

I want to store the pc name selected as a variable and pass it through to a function.

It fails. I dont understand why. Even if i put up a msgbox to display my variable, it displays empty..

If I switch to using a regular textbox, pass that through to a variable and then onto the function.. it works...

Expand|Select|Wrap|Line Numbers
  1.     Public Sub allianceChecker()
  2.  
  3.         Dim strProcess As String = "ALLIANCEMFG.EXE"
  4.  
  5.         Dim strComputer As String = frmStart.cmbMainFrm_PcList.SelectedText.ToUpper
  6.  
  7.         MessageBox.Show(strComputer)
  8.         MessageBox.Show(strProcess)
  9.  
  10.         If CheckRemoteProcess.IsProcessRunning(strComputer, strProcess) = True Then
  11.             MessageBox.Show("Yes")
  12.         Else
  13.             MessageBox.Show("no")
  14.  
  15.         End If
  16.     End Sub
  17.  
  18.  
and the function it calls:

Expand|Select|Wrap|Line Numbers
  1. Module CheckRemoteProcess
  2.     Public Function IsProcessRunning(ByVal strServer, ByVal strProcess)
  3.         Dim Process, strObject
  4.         IsProcessRunning = False
  5.         strObject = "winmgmts://" & strServer
  6.  
  7.  
  8.         For Each Process In GetObject(strObject).InstancesOf("win32_process")
  9.             If UCase(Process.name) = UCase(strProcess) Then
  10.                 IsProcessRunning = True
  11.  
  12.                 Exit Function
  13.             End If
  14.         Next
  15.         Return IsProcessRunning
  16.     End Function
  17.  
  18. End Module
  19.  
  20.  

Please advise...
Dec 5 '12 #1

✓ answered by Rabbit

I think you misunderstand what selectedText represents. selectedText represents the portion of the text that is highlighted, not the value selected item. For that, you need to use combobox.selectedItem.ToString.

5 4645
Rabbit
12,516 Expert Mod 8TB
I think you misunderstand what selectedText represents. selectedText represents the portion of the text that is highlighted, not the value selected item. For that, you need to use combobox.selectedItem.ToString.
Dec 5 '12 #2
Hi Rabbit...
Thanks for offering to help me on this -
i change the line as you suggested to
Expand|Select|Wrap|Line Numbers
  1. strComputer = frmStart.cmbMainFrm_PcList.SelectedItem.ToString.ToUpper
unfortunately this results in the same error -
Cannot create ActiveX component. this comes up when it trys to run the command against that machine. The command highlighted in the debugger is
For Each Process In GetObject(strObject).InstancesOf("win32_process")

I am not sure if its significant.. my form has a tab control in which the check button resides but outside the tab control, is my combo box
Dec 6 '12 #3
Hi again

this may also be significant..

my Combobox is filled by reading a text file

that text file is a static list of pc names - one per line

I have an update button that queries the active directory for the latest list of pcs.(Domain computers) and writes over the original text file.

The purpose is so that the application loads faster and does need to be query-ing the AD so much.

I have just noticed your method works if I query the AD first and then run my command. It does work when I pick the same item that was generated by the text file
Dec 6 '12 #4
i am sorry if I have wasted your time but I have noticed my text file includes a space after each entry. therefore it doesnt work...

either way.. your original suggestion is what got things moving

thanks very much
Dec 6 '12 #5
You should use this
Expand|Select|Wrap|Line Numbers
  1.  Dim strComputer As String = frmStart.cmbMainFrm_PcList.Text.ToUpper
Nov 20 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Peter Moscatt | last post by:
I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the...
3
by: rohith | last post by:
Hope someone can help with this. I am trying to add items to a drop down list from a database. I can do this fine by using the bind method. What I want to do also is to set the selected item to...
6
by: David De Cotis | last post by:
Hello all, I am trying to go through a ListBox and verify if am item was selected. If an item was selected, I would like to get a handle of the item and simply do a response.write on the selected...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
4
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load (page_load) i create dynamically an html table which contains a checkbox and a radiobuttonlist in each tablerow . The...
6
by: George | last post by:
Hi all, How can I get the value stored from the selected item and subitems of a listview? Thanks in advance, George
3
by: peter.mosley | last post by:
I've tried googling for the answer to this problem, without any luck. I'm sure the truth must be out there somewhere! I have a multiselect listbox populated with many items (set by the RowSource...
1
by: gubbachchi | last post by:
Hi, How can I get the selected item of the drop down box into a php variable in the same page. The options in drop down box are A,B and C and the code is here <select> <option value="Item...
1
by: Gerardo ARnaez | last post by:
Hi. I am writing a program to help determine coumadin regimens to look at the code: http://sourceforge.net/projects/coumadinregimen/ The issue is that I have a variable that I want the use to...
6
by: samvb | last post by:
I need to know how to get id of the last selected item in a multiple list box using javascript. It keeps on givin me 0 or 1...any tips would be great. Note i wanna store it in a variable and that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.