Question about Compilers & Programming Tools

1 Answer

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.

Posted by on

  • priya1803 Feb 25, 2009

    I wanted to change the backcolor of a button , rnadomly, it should keep on changing

×

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    Hot-Shot:

    An expert who has answered 20 questions.

    Corporal:

    An expert that hasĀ over 10 points.

    Mayor:

    An expert whose answer gotĀ voted for 2 times.

  • Expert
  • 53 Answers

Paste this code on you button. This generates a random color.

Red = Int(Rnd * 255)
Green = Int(Rnd * 255)
Blue = Int(Rnd * 255)


Form1.BackColor = RGB(Red, Green, Blue)

Posted on Oct 11, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Private sub cmdEdit_click ( ) what is the right code to work the edit buton


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()

rsMyRS.Edit
rsMyRS!Phone = txtPhone.Text
rsMyRS.Update

End Sub
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.

Dec 16, 2010 | Microsoft Visual Basic 6.0 for PC

1 Answer

How to install microsoft visual basic 6.0


  • Open the Web page for Microsoft Visual Studio on your computer.
  • 2 Start the download by clicking the "Download" button. Put the file somewhere where you can find it easily, such as your desktop.
  • 3 Locate the setup file "vbrun60sp5.exe" on your hard drive.
  • 4 Double click the setup file to start the installation wizard.
  • 5 Read the license agreement and click the "accept" box to begin installation.
  • 6 Follow the instructions provided by the installation wizard to install the program.


  • Read more: How to Install Visual Basic 6 ' eHow.com http://www.ehow.com/how_5896501_install-visual-basic-6.html#ixzz16RqHSTGS

    Nov 27, 2010 | Microsoft Visual Basic 6.0 for PC

    1 Answer

    How to disable command button in visual basic


  • tep 1 Open Visual Basic and select "Standard Exe" to create a new project.
  • Step 2 Add a button by clicking the square button tool on the right, and then clicking and dragging in the main window.
  • Step 3 Click the button once to open the "Properties" window on the right. Select the "(Name)" property, and type "myCmdButton" as the name.
  • Step 4 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;
  • Step 5 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.
  • Jul 07, 2010 | Microsoft Compilers & Programming Tools

    1 Answer

    How to change the background color of cells in datagridview in VB 6.0


    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

    This is how you change the backround color. 

    Feb 06, 2010 | Microsoft Visual Basic Enterprise Edition...

    1 Answer

    I want the code to open the following files(.jpg,.bmp.doc.ppt) using the command button in vb 6.0 can any one help me?


    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

    Oct 19, 2009 | Microsoft Visual Basic 6.0 for PC

    1 Answer

    Visaul basic coding for changing colour of buttons


    Just click on button and change the property of backcolor or picture

    Ok...........
    My Name is Maulik Chauhan

    And Your Self

    My Orkut id is maulik.chauhan99@gmail.com

    Jul 10, 2009 | Microsoft Visual Basic Enterprise Edition...

    1 Answer

    I want to open a jpg and doc file through command button in vb6


    try to convert it to vb6 file and open it via vb6.... heres the link >>>> http://3d2f.com/tags/vb6/converter/registered/software/

    Feb 28, 2009 | Microsoft Visual Basic 6.0 for PC

    1 Answer

    Visual basic dot net


    In the button's click event, type:

    System.Diagnostics.Process.Start("http://www.yourwebsite.com")

    Feb 18, 2009 | Microsoft Visual Basic .NET Standard 2003...

    1 Answer

    Visual Basic


    Hi Buddy,

    Create 2 buttons for previous and next in a form(say, current_form). take the previous form as 'prev_form' and next form as 'next_form' then
    write a code in the previous button command click event as

    prev_form.Show()
    current_form.Hide()

    write a code in the next button command click event as
    next_form.Show()
    current_form.Hide()

    Please let me know if you have any concerns

    Sep 02, 2008 | Compilers & Programming Tools

    Not finding what you are looking for?
    Compilers & Programming Tools Logo

    Related Topics:

    142 people viewed this question

    Ask a Question

    Usually answered in minutes!

    Top Compilers & Programming Tools Experts

    Robin Hill
    Robin Hill

    Level 3 Expert

    1251 Answers

    Fred Block
    Fred Block

    Level 2 Expert

    289 Answers

    Les Dickinson
    Les Dickinson

    Level 3 Expert

    18299 Answers

    Are you a Compiler and Programming Tool Expert? Answer questions, earn points and help others

    Answer questions

    Manuals & User Guides

    Loading...