Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Adding Combobox Values

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....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Adding Combobox Values

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" wrote in message
...
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....


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Adding Combobox Values

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" wrote in message
...
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" wrote in message
...
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....




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding Combobox Values

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 he 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" wrote in message
...
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" wrote in message
...
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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding items to ComboBox in a loop? cmpcwil2[_15_] Excel Programming 3 May 4th 06 10:31 AM
Fill values into a listbox matching selected values from a combobox Jon[_19_] Excel Programming 4 January 25th 05 04:25 PM
Adding items to a ComboBox in Excel VBA Glenn Speed Excel Programming 1 August 5th 04 07:25 AM
Dynamically adding data to a Combobox? samanathon Excel Programming 4 April 5th 04 11:26 AM
3 possible methods for adding value to a combobox Todd Huttenstine[_3_] Excel Programming 3 January 25th 04 01:16 AM


All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"