Buttons to be renamed by the user

前端 未结 1 1347
無奈伤痛
無奈伤痛 2021-01-25 15:04

I am having problems coding some of my buttons. This is what I\'ve got so far:

Public Class Form1

Dim Button(12) As Button
Dim X As Integer

Private Sub EventNa         


        
相关标签:
1条回答
  • 2021-01-25 15:34

    It sounds like you just want a person to click on a button and change the text of that button?

    If that is correct, something like this would work in your click method:

    With DirectCast(sender, Button)
      .Text = InputBox("Button Name", "Button Name", .Text)
    End With
    

    If every button needs that same input, then try something like this:

    Dim value As String = InputBox("Button Name", "Button Name")
    For Each btn As Button In Buttons
      If btn IsNot Nothing Then
        btn.Text = value
      End If
    Next
    

    You should strongly consider moving away from using that Buttons array. If you need to hold a reference of those buttons in a list, use a List(of Button) instead.

    0 讨论(0)
提交回复
热议问题