Escolar Documentos
Profissional Documentos
Cultura Documentos
htm
Search
Visual Basic
Volunteer
Answers to thousands of questions
Home · More Visual Basic Questions · Answer Library · Encyclopedia ·
Sponsored Links
My professor said in case we chose to use buttons (the hard way to do our project) we should think of
"redisplaying them everytime".
I really don't know where to start so any help would be greatly appreciated.
About Sriraman CS
Expertise
I am expertise in Visual
Thanks.
basic concepts, Office Answer -
Development, Visual Basic I don't really understand how do you choose which buttons to hide. And after you hide them, when are
for Applications (VBA) etc. I
have been using these
you unhiding them (if you're doing this)? Anyway, this will hide you some buttons:
technologies for the past
four years. You can ask any Dim k As Integer = 0
questions with regard to
Visual Basic and VBA.
For Each c As Control In Me.Controls
If k < numberOfControlsToHide Then
Experience c.Visible = False
Visual Basic 6.0, VBA
End If
k += 1
Next
Or
the following code assumes that you are providing a textbox for the user to specify how many buttons
they want to have removed. You can modify it for any other type of input you may choose to use:
1 of 4 6/10/2010 11:43 PM
Visual Basic: Hidding Buttons, users input, gettype http://en.allexperts.com/q/Visual-Basic-1048/Hidding-Buttons-1.htm
End If
End If
Next
counter = counter + 1
Loop
'If the value remains blank, do nothing, otherwise the messagebox
'will execute if the user changes the value
ElseIf txtNumber.Text = "" Then
Exit Sub
'If the value is not numeric of blank then display a messagebox
Else
MessageBox.Show ("You must enter a numeric value")
End If
End Sub
Hope this will help. Please give some more details if you need more help.
Regards,
Sriraman CS
---------
i'm designing an application for the game of nim; and well the buttons are represent the object one would
take away at a time. i'm using a textbox to input the number of items to be removed. and i'm trying to
write the loop to hide the buttons as each player inputs a number between 1 and 3.
i'm looking at your code and it's starting to make sense (this is my first CS course so i'm still fairly new to
programing)...
i came up with this
2 of 4 6/10/2010 11:43 PM
Visual Basic: Hidding Buttons, users input, gettype http://en.allexperts.com/q/Visual-Basic-1048/Hidding-Buttons-1.htm
Button7.Hide()
ElseIf Number = 5 Then
Button10.Hide()
Button9.Hide()
Button8.Hide()
Button7.Hide()
Button6.Hide()
ElseIf Number = 4 Then
Button10.Hide()
Button9.Hide()
Button8.Hide()
Button7.Hide()
Button6.Hide()
Button5.Hide()
ElseIf Number = 3 Then
Button10.Hide()
Button9.Hide()
Button8.Hide()
Button7.Hide()
Button6.Hide()
Button5.Hide()
Button4.Hide()
ElseIf Number = 2 Then
Button10.Hide()
Button9.Hide()
Button8.Hide()
Button7.Hide()
Button6.Hide()
Button5.Hide()
Button4.Hide()
Button3.Hide()
ElseIf Number = 1 Then
Button10.Hide()
Button9.Hide()
Button8.Hide()
Button7.Hide()
Button6.Hide()
Button5.Hide()
Button4.Hide()
Button3.Hide()
Button2.Hide()
ElseIf Number = 0 Then
Button10.Hide()
Button9.Hide()
Button8.Hide()
Button7.Hide()
Button6.Hide()
Button5.Hide()
Button4.Hide()
Button3.Hide()
Button2.Hide()
Button1.Hide()
End If
End Sub
it works but as you see is quite lengthy and i'm sure my professor would probably say "very inefficient".
i'll try to implement the code you gave me into my program see if i can reason it out. THANK YOU SO
MUCH! if you have any other suggestions i'll be glad to give them a read ;]
hugO
Answer
Hi,
3 of 4 6/10/2010 11:43 PM
Visual Basic: Hidding Buttons, users input, gettype http://en.allexperts.com/q/Visual-Basic-1048/Hidding-Buttons-1.htm
You need to create a control array of all your buttons. i.e., Button(0), Button(1), Button(2)...
Regards,
Sriraman CS.
Related Articles
• Working With Printers
• Create a Time Out Button / Entry Form in Delphi
• Hiding a Panel - GNOME
• Inheriting Controls in VB.NET
• The blink Element - blinking text - Netscape Tags
4 of 4 6/10/2010 11:43 PM