PC Review


Reply
Thread Tools Rate Thread

Adding Combobox Values

 
 
Corey
Guest
Posts: n/a
 
      7th Jan 2007
I have a problem with adding up the values selected in some comboboxes.

the code I was using that is NOT working is:
If ComboBox6.List(ComboBox6.ListIndex, 0) + ComboBox8.List(ComboBox8.ListIndex, 0) + ComboBox10.List(ComboBox10.ListIndex, 0) + ComboBox12.List(ComboBox12.ListIndex, 0) + ComboBox14.List(ComboBox14.ListIndex, 0) > TextBox47.Value Then

Is there a problem with the above?

I get NIL Value from it.
The list Index is correct for each.
Corey....
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      7th Jan 2007
Maube they are all strings. Try

If Val(ComboBox6.Value) + Val(ComboBox8.Value) + Val(ComboBox10.Value) +
Val(ComboBox12.Value) _ Val(ComboBox14.Value) > TextBox47.Value Then


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Corey" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
I have a problem with adding up the values selected in some comboboxes.

the code I was using that is NOT working is:
If ComboBox6.List(ComboBox6.ListIndex, 0) +
ComboBox8.List(ComboBox8.ListIndex, 0) +
ComboBox10.List(ComboBox10.ListIndex, 0) +
ComboBox12.List(ComboBox12.ListIndex, 0) +
ComboBox14.List(ComboBox14.ListIndex, 0) > TextBox47.Value Then

Is there a problem with the above?

I get NIL Value from it.
The list Index is correct for each.
Corey....


 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      7th Jan 2007
Still no values???

I am trying to set a vbyesno prompt if textbox47 < the sum of the listed
combobox values selected.
If the textbox47 value is less(<) than the sum of the comboboxes then a
msgbox(vbyesno) prompts the user to either carry on or modify to suit.
But even though the values of the comboboxes is greater (>) than the
textbox47 value i STILL get the msgbox(vbyesno)


End of commandbutton code:
~~~~~~~~~ Code ~~~~~~~~~~~~~~~~~
If ComboBox6.List(ComboBox6.ListIndex, 0) +
ComboBox8.List(ComboBox8.ListIndex, 0) +
ComboBox10.List(ComboBox10.ListIndex, 0) +
ComboBox12.List(ComboBox12.ListIndex, 0) +
ComboBox14.List(ComboBox14.ListIndex, 0) > TextBox47.Value Then
GoTo thisspot
Else

ans = MsgBox("You have Not Chosen a Combination of Lengths long enough" &
vbCrLf & vbCrLf & vbTab & " to make up the Final Length Requirement.",
vbyesno, " ....")
If ans = vbYes Then GoTo thisspot
If ans = vbNo Then
MsgBox "Please Modify the Selected Values," & vbCrLf & vbCrLf & "and try
again.", , " ...."
Exit Sub
End If
thisspot:
Unload Me
Sheets("Main").Select
Range("A1").Activate
End If
End Sub
~~~~~~~~ End Code ~~~~~~~~~~~~~~~~


Did i miss something easy ?

Corey....


"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Maube they are all strings. Try
>
> If Val(ComboBox6.Value) + Val(ComboBox8.Value) + Val(ComboBox10.Value) +
> Val(ComboBox12.Value) _ Val(ComboBox14.Value) > TextBox47.Value Then
>
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "Corey" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> I have a problem with adding up the values selected in some comboboxes.
>
> the code I was using that is NOT working is:
> If ComboBox6.List(ComboBox6.ListIndex, 0) +
> ComboBox8.List(ComboBox8.ListIndex, 0) +
> ComboBox10.List(ComboBox10.ListIndex, 0) +
> ComboBox12.List(ComboBox12.ListIndex, 0) +
> ComboBox14.List(ComboBox14.ListIndex, 0) > TextBox47.Value Then
>
> Is there a problem with the above?
>
> I get NIL Value from it.
> The list Index is correct for each.
> Corey....
>
>



 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      7th Jan 2007
the value, whether numeric in nature or not is usually stored as a string
when it is in the combobox and or a textbox

The + operator has a dual capability to act as a concatenation operator when
placed between string values.

demo'd from the immediate window:
? 1 + 2
3
? "1" + "2"
12

the 12 is a string and the result of the concatenation of 1 and 2.

If you use the val as Bob pointed out, it should convert the string values
to numbers

? val("1") + val("2")
3

Just some added info probably not an issue here: Val stops evaluating when
it hits a non numeric character. It considers a comma to be such a non
numeric character:
? val("1,000.2") + val("2,000.4")
3

Note that you should apply Val to the value of the textbox as well.

note that you can replace
ComboBox6.List(ComboBox6.ListIndex, 0)

with

Combobox6.Value

If Val(Combobox6.Value) + _
Val(Combobox8.Value) + _
Val(Combobox10.Value) + _
Val(Combobox12.Value) + _
Val(Combobox14.Value) >
Val(TextBox47.Value) then


--
Regards,
Tom Ogilvy



"Corey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Still no values???
>
> I am trying to set a vbyesno prompt if textbox47 < the sum of the listed
> combobox values selected.
> If the textbox47 value is less(<) than the sum of the comboboxes then a
> msgbox(vbyesno) prompts the user to either carry on or modify to suit.
> But even though the values of the comboboxes is greater (>) than the
> textbox47 value i STILL get the msgbox(vbyesno)
>
>
> End of commandbutton code:
> ~~~~~~~~~ Code ~~~~~~~~~~~~~~~~~
> If ComboBox6.List(ComboBox6.ListIndex, 0) +
> ComboBox8.List(ComboBox8.ListIndex, 0) +
> ComboBox10.List(ComboBox10.ListIndex, 0) +
> ComboBox12.List(ComboBox12.ListIndex, 0) +
> ComboBox14.List(ComboBox14.ListIndex, 0) > TextBox47.Value Then
> GoTo thisspot
> Else
>
> ans = MsgBox("You have Not Chosen a Combination of Lengths long enough" &
> vbCrLf & vbCrLf & vbTab & " to make up the Final Length Requirement.",
> vbyesno, " ....")
> If ans = vbYes Then GoTo thisspot
> If ans = vbNo Then
> MsgBox "Please Modify the Selected Values," & vbCrLf & vbCrLf & "and try
> again.", , " ...."
> Exit Sub
> End If
> thisspot:
> Unload Me
> Sheets("Main").Select
> Range("A1").Activate
> End If
> End Sub
> ~~~~~~~~ End Code ~~~~~~~~~~~~~~~~
>
>
> Did i miss something easy ?
>
> Corey....
>
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Maube they are all strings. Try
>>
>> If Val(ComboBox6.Value) + Val(ComboBox8.Value) + Val(ComboBox10.Value) +
>> Val(ComboBox12.Value) _ Val(ComboBox14.Value) > TextBox47.Value Then
>>
>>
>> --
>> HTH
>>
>> Bob Phillips
>>
>> (replace somewhere in email address with gmail if mailing direct)
>>
>> "Corey" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>> I have a problem with adding up the values selected in some comboboxes.
>>
>> the code I was using that is NOT working is:
>> If ComboBox6.List(ComboBox6.ListIndex, 0) +
>> ComboBox8.List(ComboBox8.ListIndex, 0) +
>> ComboBox10.List(ComboBox10.ListIndex, 0) +
>> ComboBox12.List(ComboBox12.ListIndex, 0) +
>> ComboBox14.List(ComboBox14.ListIndex, 0) > TextBox47.Value Then
>>
>> Is there a problem with the above?
>>
>> I get NIL Value from it.
>> The list Index is correct for each.
>> Corey....
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto make Combobox requery based on dependant combobox values Shane Microsoft Access Form Coding 1 22nd Apr 2008 09:14 AM
Adding values to a combobox from a set of ENUM constants from web =?Utf-8?B?UmljaGFyZCBUb2NjaQ==?= Microsoft Dot NET 2 19th Jun 2007 03:30 PM
adding values to unbound combobox =?Utf-8?B?Tmljaw==?= Microsoft Access VBA Modules 1 22nd May 2006 03:52 PM
Dynamically adding values to bound combobox?? Aaron Ackerman Microsoft VB .NET 5 28th Oct 2003 02:12 AM
Dynamically adding values to bound combobox?? Aaron Ackerman Microsoft Dot NET 3 27th Oct 2003 04:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:32 AM.