문제

How I can take the text of the button to use it like a resource name?

My try:

Public Sub LlamadaButton(ByVal sender As Object, ByVal e As System.EventArgs)
   Dim ButtonN As Button = CType(sender, Button)
   Dim ResourceName = ButtonN.Text
   ReadDelimitedText(My.Resources._(ResourceName), ";")     ' The problem: My.Resources._(ResourceName)
   End Sub

Error: Identifier expected

도움이 되었습니까?

해결책

Use the My.Resources.ResourceManager.GetString Method.

Dim ResourceName = ButtonN.Text
ReadDelimitedText(My.Resources.ResourceManager.GetString("_" & ResourceName), ";")     

다른 팁

<script runat="server">
Public Sub LlamadaButton(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  Dim ButtonN As Button = CType(sender, Button)
  Dim ButtonText = ButtonN.Text
  MsgBox(ButtonText)
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button Bob" />
    </div>
  </form>
</body>
</html>

Is this what you mean?, clicking on the button will show the text in a messagebox, try and change the button text and click it again

Assuming your resource file name is Resource1.resx, and your string in it is String1, you should be able to access it like this:

My.Resources.Resource1.String1
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top