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

Was it helpful?

Solution

Use the My.Resources.ResourceManager.GetString Method.

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

OTHER TIPS

<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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top