Member Avatar for breezyy

Hey there,
I have the following problem driving me nuts!
I have 2 check boxes and each one is assigned a message (for check 1 say Hi, for check 2 say food). If I click on one of them, it displays its message in a text box, and pressing the second one, (with the 1st one still ticked) should display both messages. Problem is, one is overwriting the other, and vice-versa. Any tips?

use if end if or case statement.
if check1.value = 1 then
text1.text = hi
else
text1.text= ""
end if

Hi,

You need to build the message string accordingly..
Try This :

Dim T As String
T= ""
If chk1.Value = vbChecked Then
  T = "Hi  "
End If
If chk2.Value = vbChecked Then
  T = T & " Food  "
End If

MsgBox T

Regards
Veena

Member Avatar for breezyy

Hi,

You need to build the message string accordingly..
Try This :

Dim T As String
T= ""
If chk1.Value = vbChecked Then
  T = "Hi  "
End If
If chk2.Value = vbChecked Then
  T = T & " Food  "
End If

MsgBox T

Regards
Veena

That was a real life saver!
In fact the error I made was using T = T And " Food " instead of T = T & " Food "
Thanks for the tip !
Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.