Question

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

Était-ce utile?

La solution

Use the My.Resources.ResourceManager.GetString Method.

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

Autres conseils

<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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top