Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > Not "And" then which command?
 

Not "And" then which command?

ok i have put colour code in one of my projects here is the code: 

    Try
            Dim dlg As ColorDialog = New ColorDialog
            dlg.Color = Button1 And Button2.BackColor
            If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                Button1 and button2.BackColor = dlg.Color
            End If
        Catch ex As Exception : End Try
    End Sub
End Class


OK here is the probelm i experience, i want 2 objects to change colour but since you cant put the word "and" in which command will it be?
Asim09  Friday, October 16, 2009 9:25 PM
 Try
            Dim dlg As ColorDialog = New ColorDialog
                  dgl.color=button1.backcolor
                        If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                Button1.backclor=dlg.clor
 button2.BackColor = dlg.Color
            End If
        

Catch

 

excp As Exception

MsgBox(excp.Message + excp.StackTrace)


End Try
    End Sub
End Class

Don't judge me, just Upgrade me. Thanks!
Malange  Friday, October 16, 2009 9:31 PM
you can use--------------------- AndAlso
Don't judge me, just Upgrade me. Thanks!
Malange  Friday, October 16, 2009 9:53 PM
ok i have put colour code in one of my projects here is the code:

Try
Dim dlg As ColorDialog = New ColorDialog
dlg.Color = Button1 And Button2.BackColor
If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
Button1 and button2.BackColor = dlg.Color
End If
Catch ex As Exception : End Try
End Sub
End Class


OK here is the probelm iexperience, i want 2 objects to change colour but since you cant put the word "and" in which command will it be?

hi, yeah you can't use AND in this way. AND is used to 'combine' boolean values, like a logic circuit.

you need to set the color on two lines on code, some languages let you do this...

button1.color = button2.color = color.blue

but VB doesn't
Derek Smyth  Saturday, October 17, 2009 10:23 PM

You can use google to search for other answers

Custom Search

More Threads

• Getting the project directory
• Obtaining a list of fonts installed on the system
• Help an old school guy out!
• how to load automacticaly tabs
• replacing the VB6 String$ function
• i need some help
• How to make a connected microsoft access data relative
• 15
• Removing characters from a string
• needs help for closing window