Shoutbox

need help in visual basic.... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: need help in visual basic.... (/showthread.php?tid=48236)

need help in visual basic.... by TheMusicPirate on 07-28-2005 at 05:35 PM

how can i do these things?

i want to link from a command buton to another form

and i want to have options to be able to change the colors of the font and change the background.



thanks.


RE: need help in visual basic.... by Mike on 07-28-2005 at 05:44 PM

To show another form:

code:
frmName.Show

To change the background colour of the form:

code:
frmName.BackColor = vbBlack 'Black

And for the font colour...
Well, try doing something like this:

code:
Dim ctrl as Control
For Each ctrl in Me 'If this doesnt work, try changing Me to Controls
    If TypeOf ctrl is label then
ctrl.Forecolor = vbWhite 'White
Next ctrl

RE: RE: need help in visual basic.... by TheMusicPirate on 07-28-2005 at 05:49 PM

quote:
Originally posted by Mike
To show another form:

code:
frmName.Show

To change the background colour of the form:

code:
frmName.BackColor = vbBlack 'Black

And for the font colour...
Well, try doing something like this:

code:
Dim ctrl as Control
For Each ctrl in Me 'If this doesnt work, try changing Me to Controls
    If TypeOf ctrl is label then
ctrl.Forecolor = vbWhite 'White
Next ctrl


is there a way for the font and colors, that i can just have them as option buttons?
RE: need help in visual basic.... by CookieRevised on 07-29-2005 at 01:06 AM

Not to be rude or something, but why don't you just press F1 (aka read the help files)?

You also can simply type an object's name, enter the point, and a dropdown list will be shown with all available properties... scroll that list and look at the names...

Also, check out the properties window of controls. They very clearly show each property of a control and you cant miss the COLOR settings in there...

[Image: attachment.php?pid=503704]


The stuff you ask for is extremly low level basic knowledge though. Did you read a tutorial on VB first? Or a manual or tut like "VB in 10 steps", "VB for beginners", etc...? As I said, I'm not trying to be rude, but looking at your questions it seems to me that you just begun programming in VB. So it wouldn't hurt if you first read some basic programming tuts for VB (which can be found by thousands on the net). Because if you're stuck with these basic things already, you wont get very far...


---------

quote:
Originally posted by TheMusicPirate
is there a way for the font and colors, that i can just have them as option buttons?
Think like a program....

1) What do you want to do? change a color of a control => change the correct property of a control (.forecolor, .font, etc)
2) How do you determine which color? by the radio buttons => use an "if..then..else", "Select Case", or whatever decision making statement.
3) How do you change the buttons? by clicking the radio buttons => put it in the "Click()" event of the radio buttons.

Tell yourself in plain decent english what you need to do exactly and you will have your solution:
"If radio button 1 is selected then change the background color of form1 to black"
"If radio button 2 is selected then change the background color of form1 to red"

Sub Option_Click(Index As Integer)
  If Option(0).Value = True Then Form1.Backcolor = vbBlack
  If Option(1).Value = True Then Form1.Backcolor = vbRed
  If Option(2).Value = True Then Form1.Backcolor = vbGreen
  If Option(3).Value = True Then Form1.Backcolor = vbBlue
  'etc...
End Sub


in a better way:

Sub Option_Click(Index As Integer)
  If Option(0).Value = True Then
    Form1.Backcolor = vbBlack
  ElseIf Option(1).Value = True Then
    Form1.Backcolor = vbRed
  ElseIf Option(2).Value = True Then
    Form1.Backcolor = vbGreen
  ElseIf Option(3).Value = True Then
    Form1.Backcolor = vbBlue
  End If
End Sub

And because you have heaps of simple if..then..else statements, and because the Click() event is triggered when you click (thus select!) a button it is much better to use:

Sub Option_Click(Index As Integer)
  'Index is the index of the radio button which was pressed. See the properties toolwindow!
  Select Case Index
      Case 0
          Form1.Backcolor = vbBlack
      Case 1
          Form1.Backcolor = vbRed
      Case 2
          Form1.Backcolor = vbGreen
      Case 3
          Form1.Backcolor = vbBlue
  End Select
End Sub