Results 1 to 13 of 13

Thread: cmd button shape

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    9

    cmd button shape

    I need help in changing the shape of a command button to a circle. This is my 1st time using VB. what i am doing is making a stand along program that looks like the control panel of the machine I work on. This is to train operators in a classroom. I have completed half of the program but dont like the 4 sided cmd button.
    Any help will be great.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: cmd button shape

    Welcome to the Forums.

    Creating elipictical shaped buttons is a bit advanced if you are new to vb.
    There are thrid party controls that can do this for you very easily.

    If you really want to try it, you can simulate one easier by using images and
    a picturebox control. One image for up, one for down, and one for disabled,
    etc. Then in each event, switch the images to correspond to the event,
    Mouse_Down, Mouse_Up, Command_Click, etc.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: cmd button shape

    I've done this sample for someone ages ago but I gues it just comes handy once in awhile. It clearly demonstrates what Rob suggested with images.
    It's a quick sample and should treated as one.

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    9

    Re: cmd button shape

    The cmb button shape did not work for me so i tried this.
    made a label transperent and placed a circle shape on top with Backcolor yellow.
    setup code so.
    Private sub label5_click()
    shape1.Backcolor = &HFF00&
    Endsub
    This works great it changes from yellow to green but how can i get it to toggle between the 2 colors every time i click the label.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: cmd button shape

    use a flag that's booloean

    Code:
    Dim flag As Boolean
    flag=true
    shape1.Backcolor = vbyellow
    
    Private Sub label5_click()
      If flag=true Then
         shape1.Backcolor = &HFF00&
         flag=false
      Else
         shape1.Backcolor = vbyellow
         flag=true
      endif
    Exit Sub

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    9

    Re: cmd button shape

    I tried the code on a new form but keep getting this error.

    Compile error:
    Invalid outside procedure

  7. #7
    Registered User HellRaider's Avatar
    Join Date
    Sep 2003
    Posts
    70

    Post Re: cmd button shape

    This makes a command button, scrollbar, list control, option box and a check box all round as well as the form.

    I hope it helps.
    Attached Files Attached Files

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: cmd button shape

    the first three lines go into your form, and the rest replaces your code.

  9. #9

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    9

    Re: cmd button shape

    Thanks for the help but with the code you all showed I kept getting errors.
    So after a good drink i fixed it like so.
    Private Sub label5_click()
    If Shape1.BackColor = &HFFFF& Then
    Shape1.BackColor = &HFF00&
    Else: Shape1.BackColor = &HFFFF&
    End If
    End Sub

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: cmd button shape

    I guess that it will work, but flags really are a good thing to know.

  11. #11

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    9

    Resolved Re: cmd button shape

    As the name states I am a newbie. Just picked up a book Beginning VB6 by Peter Wright a week ago and am trying to make a interactive operators manual to help me train operators on the machinery i install.
    I might have bitten of more than i can chew but you got to start some where.
    THANK FOR THE HELP.
    There will be more questions as i progress
    Last edited by newbie 2 vb; Jan 3rd, 2005 at 02:17 AM. Reason: Resolved

  12. #12
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444

    Re: cmd button shape

    you might want to move the label too if you want it to look realistic (only if 3d type button), but you'll have to use public vars for original label position because using, for example, label1.left = label1.left + 10 for down event and label1.left = label1.left - 10 for up event might cause problems. Should be for down event
    VB Code:
    1. originallabel1left = label1.left
    2. label1.left = label1.left + 10

    and
    label1.left = originallabel1left
    for up event. Same for .top to move it up and down

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: cmd button shape

    Here is a quick sample that i did. paste it in, after deleting all code.
    The first line is above everything else, and will go in the General Declarations section of the form.

    Public Flag As Boolean

    Private Sub btnSwitch_Click()
    If Flag = True Then
    lblMessage.BackColor = vbWhite
    lblMessage.ForeColor = vbRed
    lblMessage.Caption = "This it False"
    Flag = False
    Else
    lblMessage.BackColor = vbBlack
    lblMessage.ForeColor = vbWhite
    lblMessage.Caption = "This it True"
    Flag = True
    End If
    End Sub

    Private Sub Form_Load()
    lblMessage.BackColor = vbBlack
    lblMessage.ForeColor = vbWhite
    lblMessage.Caption = "This it True"
    Flag = True
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width