In visual basic how will we change the backcolor of the form randomly when we click the command button?
In this program we want to change the background color of the form by command button when we click on this it will change the bakground color.
everytime when we'll run the program it chose the different color.
- If you need clarification, ask it in the comment box above.
- Better answers use proper spelling and grammar.
- Provide details, support with references or personal experience.
Tell us some more! Your answer needs to include more details to help people.You can't post answers that contain an email address.Please enter a valid email address.The email address entered is already associated to an account.Login to postPlease use English characters only.
Tip: The max point reward for answering a question is 15.
You will probably want to be able to update some value of some field when doing database programming. This is done with Edit and Update. We will try to change the value of the "Phone" field by editing the text in the text box
and clicking a button.
Put a command button on the form and name it "cmdUpdate". Then copy the following code to the project.
Private Sub cmdUpdate_Click()
Could it be that simple? Yes. This changes the phone number of our
selected person. Or to put it technically: This changes the value of the
"Phone" field of our current record. Imagine the current record being a
set of boxes, with a field in each box. T
he Edit method takes the lid off all of the boxes and Update puts them back on. When we write rsMyRS!Phone = txtPhone.Text we replace the content of the "Phone" box with the content in the text box.
Open Visual Basic and select "Standard Exe" to create a new project.
Add a button by clicking the square button tool on the right, and then clicking and dragging in the main window.
Click the button once to open the "Properties" window on the right. Select the "(Name)" property, and type "myCmdButton" as the name.
Double-click the button to open up the code-view window. Type the following in the white space under "Private Sub myCmdButton_Click()": myCmdButton.enabled = False;
Click the blue "Run" button on the top toolbar of Visual Basic. Because you set enabled to "false" in the previous step, you will see your button grayed out, and nothing will happen when you click it.
Use the "Style" property DataGridView1.Item(ColumnIndex, RowIndex).Style.BackColor = Color DataGridView1.Item(ColumnIndex, RowIndex).Style.ForeColor = Color or DataGridView1.CurrentCell.Style.BackColor = Color DataGridView1.CurrentCell.Style.ForeColor = Color
Are you looking for Open Dialog box options? Then this can help you... http://vbadud.blogspot.com/2007/06/visual-basic-common-dialog.html even look at this too.. http://msdn.microsoft.com/en-us/library/256tssz7.aspx