How is the ComboBox.Text working 
Author Message
 How is the ComboBox.Text working

Hi All,

I created a ComboBox which include Values. The Value are shown in the List
plus a description.

Like:        255 Maximum

When I choose one of these Values out of the list I have to use only the 255
and not the description.
So what I do is to read the ListIndex then I use these Index for an array in
which I find the plain value again.
The Problem is when I will give these Value to the Text field it does'nt
work.
The Combobox Textfield will be empty after that.

My Example

Private Sub cboChooseValue_Click(Index As Integer)

cboChooseValueListIndex = cboChooseValue(Index).ListIndex

cboChooseValue(Idex).Text=
Info(ActualIndex).Ref(cboChooseValueListIndex).Value

Debug.Print Info(ActualIndex).Ref(cboChooseValueListIndex).Value

End Sub

Is there anybody with an Idea

Thanks in Advance

Patrick



Sun, 25 May 2003 03:00:00 GMT  
 How is the ComboBox.Text working
Hi Patrick:

Quote:
> So what I do is to read the ListIndex then I use these Index for an array
in
> which I find the plain value again.

Why don't you use the ItemData property?  i.e.

   With cboChoose
      .AddItem "255 Maximum"
      .ItemData(.NewIndex) = 255
   End With

Then when you need to find a value:

   With cboChoose
      If .ListIndex > -1 Then
         Value = .ItemData(.ListIndex)
      End If
   End With

Quote:
> The Problem is when I will give these Value to the Text field it does'nt
> work.
> The Combobox Textfield will be empty after that.

I really don't follow what you are trying to do here... why are you trying
to re-assign the text back to the combo?

Hope this helps,

Doug.



Sun, 25 May 2003 03:00:00 GMT  
 How is the ComboBox.Text working
Hi Doug,

thanks for your response I have still problems with the ComboBox.
My task is to show the user an Reference Value
like these:

Reference Choose      < First Textfield
255 Maximum           < List of ComboBox
127 Half
0   Minimum

I get these List Information out of 2 Data Arrays one for
the Value one for the Description.
When the user choose one of these list entries only
the Value without the description shall be shown and
send direct via dll to another machine.
My problem is still to get these Value out of the list
without the description into the "First" textfield in
the ComboBox.
Your solution seemed not to be run as well, maybay you
hav got another Idea.

Thank's a lot

Patrick


Quote:
> Hi Patrick:

> > So what I do is to read the ListIndex then I use these Index for an
array
> in
> > which I find the plain value again.

> Why don't you use the ItemData property?  i.e.

>    With cboChoose
>       .AddItem "255 Maximum"
>       .ItemData(.NewIndex) = 255
>    End With

> Then when you need to find a value:

>    With cboChoose
>       If .ListIndex > -1 Then
>          Value = .ItemData(.ListIndex)
>       End If
>    End With

> > The Problem is when I will give these Value to the Text field it does'nt
> > work.
> > The Combobox Textfield will be empty after that.

> I really don't follow what you are trying to do here... why are you trying
> to re-assign the text back to the combo?

> Hope this helps,

> Doug.



Mon, 26 May 2003 03:00:00 GMT  
 How is the ComboBox.Text working
Hi Patrick:

I am having a hard time trying to understand what you are doing, but...

Quote:
> When the user choose one of these list entries only
> the Value without the description shall be shown and
> send direct via dll to another machine.

Shown where?  Are you having problems figuring out the value?

Quote:
> My problem is still to get these Value out of the list
> without the description into the "First" textfield in
> the ComboBox.

Getting the value is not problem -- just store it in the ItemData and use
that, i.e.

   Private Sub cboChoose_Click()
      If cboChoose.ListIndex > -1 Then
         cboChoose.Text = cboChoose.ItemData(cboChoose.ListIndex)
      End If

      'Note:  You also could get away with using Val instead of the
ItemData, i.e.
      'If cboChoose.ListIndex > -1 Then
      '   cboChoose.Text = Val(cboChoose.Text)
      'End If
   End Sub

If the above doesn't help, then post a code example showing exactly what you
are doing - -maybe I can figure out a solution from that.

Hope this helps,

Doug.



Mon, 26 May 2003 23:15:27 GMT  
 How is the ComboBox.Text working
I believe he has an item in the combo box with a value of '255 Maximum' and
when a user selects this item, he only wants '255' to show in the Text
portion...


Quote:
> Hi Patrick:

> I am having a hard time trying to understand what you are doing, but...

> > When the user choose one of these list entries only
> > the Value without the description shall be shown and
> > send direct via dll to another machine.

> Shown where?  Are you having problems figuring out the value?

> > My problem is still to get these Value out of the list
> > without the description into the "First" textfield in
> > the ComboBox.

> Getting the value is not problem -- just store it in the ItemData and use
> that, i.e.

>    Private Sub cboChoose_Click()
>       If cboChoose.ListIndex > -1 Then
>          cboChoose.Text = cboChoose.ItemData(cboChoose.ListIndex)
>       End If

>       'Note:  You also could get away with using Val instead of the
> ItemData, i.e.
>       'If cboChoose.ListIndex > -1 Then
>       '   cboChoose.Text = Val(cboChoose.Text)
>       'End If
>    End Sub

> If the above doesn't help, then post a code example showing exactly what
you
> are doing - -maybe I can figure out a solution from that.

> Hope this helps,

> Doug.



Tue, 27 May 2003 00:49:21 GMT  
 How is the ComboBox.Text working


Quote:
> I believe he has an item in the combo box with a value of '255 Maximum'
and
> when a user selects this item, he only wants '255' to show in the Text
> portion...

Then he's out of luck, as you know.


Tue, 27 May 2003 01:24:01 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. text selection with mouse not working in combobox

2. Combobox and matching text contents to the combobox list

3. ComboBox text to textBox dif Text

4. shared variable not working what am I missing?

5. I am working on cool project, looking for creative idea to help

6. What am I doing wrong?? (working with Inet)

7. ScaleHeight/ScaleWidth with borderless form - Not working, please help I am stumped

8. I am lokking for a professional who works with visual basic, poerbuilder, and C++

9. Hi, I am having trouble with bar code font not working

10. Text Form Field Help Text - Does it work?

11. VB4 text box Align text property not working

12. VB4 text box Align text property not working

 

 
Powered by phpBB® Forum Software