View previous topic :: View next topic |
Author |
Message |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Wed Apr 01, 2009 2:35 pm Post subject: help with vb 2008 code |
|
|
ok i am working on a way to make a button background color to change useing a timer so far i got Code: | Button1.BackColor = Color.Orange | but i am not sure What to put after that or anything if you help me and it works +rep
Edit: i also want to know how to do it with background immages _________________
|
|
Back to top |
|
 |
cheesecan Expert Cheater
Reputation: 0
Joined: 01 Oct 2006 Posts: 215
|
Posted: Wed Apr 01, 2009 3:01 pm Post subject: Re: help with vb 2008 code |
|
|
rayz321 wrote: | ok i am working on a way to make a button background color to change useing a timer so far i got Code: | Button1.BackColor = Color.Orange | but i am not sure What to put after that or anything if you help me and it works +rep
Edit: i also want to know how to do it with background immages |
Im pretty sure with visual basic you can just put it in a on click event
maybe try this ?
Button1.BackColor = Color.FromName("Red") |
|
Back to top |
|
 |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Wed Apr 01, 2009 3:08 pm Post subject: |
|
|
but i want it to do it automatically and change colors at a set interval
Edit: mabey the colors could be random but still not sure how to do what i asked in the first post _________________
|
|
Back to top |
|
 |
Karakawe I post too much
Reputation: 3
Joined: 17 Apr 2007 Posts: 3899
|
Posted: Wed Apr 01, 2009 3:14 pm Post subject: |
|
|
There's a General Programming section if you want to give that a go. (Never bothered with VB, sorry.) |
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
|
Back to top |
|
 |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Wed Apr 01, 2009 6:02 pm Post subject: |
|
|
slovach wrote: | http://msdn.microsoft.com/en-us/library/system.drawing.color.fromargb.aspx |
how i use it i dont get how ? _________________
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 01, 2009 6:08 pm Post subject: |
|
|
Write a routine that cycles colors by gradually going through RGB... |
|
Back to top |
|
 |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Wed Apr 01, 2009 6:36 pm Post subject: |
|
|
slovach wrote: | Write a routine that cycles colors by gradually going through RGB... | um sorry but what does that mean _________________
|
|
Back to top |
|
 |
Jorg hi I post too much
Reputation: 7
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 01, 2009 9:07 pm Post subject: |
|
|
Why do you have .ToString there? |
|
Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Apr 02, 2009 3:38 am Post subject: |
|
|
Code: |
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Namespace ColorTune
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
r = startColor(0)
g = startColor(1)
b = startColor(2)
End Sub
Private startColor As Integer() = {0, 0, 0}
Private endColor As Integer() = {255, 255, 255}
Private r As Integer, g As Integer, b As Integer
Private rand As New Random()
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.BackColor = Color.FromArgb(startColor(0), startColor(1), startColor(2))
Me.timer1.Enabled = True
End Sub
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
r += rand.[Next](0, 10)
If r > endColor(0) Then
r = startColor(0)
End If
g += rand.[Next](0, 10)
If g > endColor(1) Then
g = startColor(1)
End If
b += rand.[Next](0, 10)
If b > endColor(2) Then
b = startColor(2)
End If
Me.BackColor = Color.FromArgb(r, g, b)
End Sub
End Class
End Namespace |
slovach, why is my code fucked up :/ _________________
Intel over amd yes. |
|
Back to top |
|
 |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Thu Apr 02, 2009 1:54 pm Post subject: |
|
|
Jorg hi wrote: | .Lol I don't know if you want this but I do think it is cool
Timer Code:
Code: |
me.button1.timer1.Interval = 100
On Error Resume Next
me.button1.BackColor = Color.FromArgb(Math.Round(-(Control.MousePosition.X.ToString & Control.MousePosition.Y.ToString), 10)) |
Lol I love this code and I am always modifying it. |
ok it works prety good
to guy in last post befor me your code did not work for my vb 2008 it said santax error for imports and one other thing i think _________________
|
|
Back to top |
|
 |
shhac Expert Cheater
Reputation: 0
Joined: 30 Oct 2007 Posts: 108
|
Posted: Thu Apr 02, 2009 2:06 pm Post subject: |
|
|
slovach wrote: | Why do you have .ToString there? | To let him use the & operator to make the two numbers into one longer number, e.g. if X was 345 and Y was 781 then it would produce 345781 as a string and then this gets implicitly changed back to an float/simple because it is in the Math.Round function.
@Naablet you don't have any handles assigned to any of what you posted.
Nobody seemed to really answer rayz321's original question.
In the designer, double click on timer from the list on the left, then left click on the new timer at the bottom (probably Timer1) once so you can change the properties, set enabled to true and the interval how often you want the colour to change in milliseconds. Next, double click on the timer and in the new Sub that has now been made automatically add this (or one of the other codes of your choosing) Code: | Button1.BackColor = Color.FromArgb((New Random).Next(0,256), (New Random).Next(0,256), (New Random).Next(0,256)) |
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Apr 02, 2009 4:15 pm Post subject: |
|
|
huh, didn't know & is also for string concatenation in VB. |
|
Back to top |
|
 |
shhac Expert Cheater
Reputation: 0
Joined: 30 Oct 2007 Posts: 108
|
Posted: Thu Apr 02, 2009 4:37 pm Post subject: |
|
|
Do not many people on this forum know VB.NET? =/ I've been looking at the level of questions that've been answered and those that haven't and I'm beginning to doubt that the question I asked (a few threads down) will be answered. |
|
Back to top |
|
 |
|