What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Command Button VB Help

Pages: (2): « First « 1 [ 2 ] Last »
Command Button VB Help
Author: Message:
.blade//
Veteran Member
*****

Avatar

Posts: 2856
Reputation: 39
35 / Male / –
Joined: Jan 2004
RE: Command Button VB Help
quote:
Originally posted by mwe99
nope still comes up red... here look

it doesn't seem to like the & sign

i have the colour going in the box... i just need something to tell the other colours to go to the next box

so after cmdfinal1 has been filled, automatically make the next colour go to cmdfinal2




Well try this code:

(If your version of VB recognises "ME" - otherwise replace "me" with the box name)

code:

"C" & selector.backcolor = me.backcolor
If selector =< 4 then
selector = selector + 1
end if



This post was edited on 04-28-2005 at 06:04 PM by .blade//.
[Image: A%20Pointy%20Rock.jpg]
04-28-2005 06:03 PM
Profile PM Web Find Quote Report
mwe99
Veteran Member
*****

Avatar

Posts: 2514
Reputation: 67
36 / Male / Flag
Joined: Jul 2004
O.P. RE: Command Button VB Help
Whats the selector then? the cmdfinal1 ?
04-28-2005 06:09 PM
Profile PM Find Quote Report
.blade//
Veteran Member
*****

Avatar

Posts: 2856
Reputation: 39
35 / Male / –
Joined: Jan 2004
RE: Command Button VB Help
quote:
Originally posted by mwe99
Whats the selector then? the cmdfinal1 ?




:| I told you before - selector is a variable with a number which is between 1 and 4. Every time a colour is picked, the number goes up - so that C & selector always gives you the right selection.
[Image: A%20Pointy%20Rock.jpg]
04-28-2005 06:12 PM
Profile PM Web Find Quote Report
Millenium_edition
Veteran Member
*****

Avatar

Posts: 1787
Reputation: 57
Joined: Apr 2003
RE: Command Button VB Help
if you would have used arrays of buttons, you'd only have to write one procedure and it would have been much easier. :-/
04-28-2005 06:15 PM
Profile E-Mail PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Command Button VB Help
code:

"C" & selector.backcolor = me.backcolor
If selector =< 4 then
selector = selector + 1
end if



I really can't see how that's meant to work. It's not logical, and it obviously doesn't work as mwe has said three times it highlights it in red.

What is ""C" & selector.backcolor "? You can't dynamically concatenate a backcolor onto the end of a string and set it to something. You make no sense.
The previous sentence is false. The following sentence is true.
04-28-2005 09:08 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Command Button VB Help
quote:
Originally posted by mwe99
lol wow am i confused :P
no wonder :P

First of all disregard everything Blade has said... sorry Blade, but yours make no sense at all. As Segosa said, that isn't even logic programming code.

quote:
Originally posted by Millenium_edition
if you would have used arrays of buttons, you'd only have to write one procedure and it would have been much easier. :-/
indeed. And this is the way to go for something like this...

code:
Option Explicit

Dim CurrentBox As Byte

Private Sub Form_Load()
  CurrentBox = 1
  Call ClearBoxes
End Sub

Private Sub cmdColor_Click(Index As Integer)
  cmdFinal(CurrentBox).BackColor = cmdColor(Index).BackColor
  CurrentBox = CurrentBox + 1
  If CurrentBox = 5 Then
    Call Validate
    '
    CurrentBox = 1
    Call ClearBoxes
  End If
End Sub
see attached zip for full example code

.zip File Attachment: Form1.zip (1.16 KB)
This file has been downloaded 87 time(s).
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-29-2005 08:41 AM
Profile PM Find Quote Report
mwe99
Veteran Member
*****

Avatar

Posts: 2514
Reputation: 67
36 / Male / Flag
Joined: Jul 2004
O.P. RE: Command Button VB Help
It still makes the code red:s

i don't know why but its not seeming to accept the code so i deleted the code,


i attached this to see if anyone can see the solution.

.zip File Attachment: Mastermind(1).zip (125.52 KB)
This file has been downloaded 91 time(s).
04-29-2005 07:09 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Command Button VB Help
quote:
Originally posted by mwe99
It still makes the code red:s

i don't know why but its not seeming to accept the code so i deleted the code
We said to disregard Blade's code as that isn't even logical programming code and will never work in any programming language.

quote:
Originally posted by mwe99
i attached this to see if anyone can see the solution.
1) The code you're working in is "VBA" (aka "Visual Basic for Applications"). This is not the same as "Visual Basic" which we were all talking about (although many things are similar)!

2) Look at my code which I attached in the zipfile in my previous post and the related comments... The thing you need to change is to add the code for the colorbutton to each individual color button on your form, as VBA doesn't support array's of controls, the rest of the principle is just the same.
EDIT: I've edited your Excel sheet with working code for that particular form (see attachment in this post).

.zip File Attachment: Mastermind(2).zip (115.76 KB)
This file has been downloaded 98 time(s).

This post was edited on 04-30-2005 at 03:58 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-30-2005 02:20 AM
Profile PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On