0

I'm trying to make an inline keyboard Telegram Bot but I find an error when I convert from c# to vb.net:

Private Shared Function GetInlineKeyboard(ByVal stringArray As String()) As InlineKeyboardButton()()
    Dim keyboardInline = New InlineKeyboardButton(0)() {}
    Dim keyboardButtons = New InlineKeyboardButton(stringArray.Length - 1) {}
    For i = 0 To stringArray.Length - 1
        keyboardButtons(i) = New InlineKeyboardButton With {.Text = stringArray(i), .CallbackData = "Some Callback Data"}
    Next

    keyboardInline(0) = keyboardButtons
    Return keyboardInline
End Function

This result code from convert c# to vb.net but I'm getting error in:

keyboardButtons(i) = New InlineKeyboardButton With {.Text = stringArray(i), .CallbackData = "Some Callback Data"}

They said: "Initializes a new instance of the InlineKeyboardButton Class.

'New' cannot be used on a Class that is declared 'MustInherit'"

I don't know what I have to do. I'm new in vb.net.

Sorry for my bad english

Jimi
  • 29,621
  • 8
  • 43
  • 61
  • in c# talk that means that the class is abstract - you cant create instances of abstract classes – pm100 May 03 '18 at 02:17
  • so what i have to do ??? can you give me example in vb.net ??? – Sutrasno Andre Wibowo May 03 '18 at 02:19
  • What you have to do is not try to create an instance of a class that you can't create an instance of. Beyond that, it's up to you. You need to determine what class you should be creating an instance of and create an instance of it. That's not a question for us. Find out what classes inherit `InlineKeyboardButton` and which one you need to use. – jmcilhinney May 03 '18 at 02:24
  • you said you are converting c# code, you clearly are not converting it correctly since the c# code would have failed the same way. Show the equivalent working c# code – pm100 May 03 '18 at 02:26
  • private static InlineKeyboardButton[][] GetInlineKeyboard(string [] stringArray) { var keyboardInline = new InlineKeyboardButton[1][]; var keyboardButtons = new InlineKeyboardButton[stringArray.Length]; for (var i = 0; i < stringArray.Length; i++) { keyboardButtons[i] = new InlineKeyboardButton { Text = stringArray[i], CallbackData = "Some Callback Data", }; } keyboardInline[0] = keyboardButtons; return keyboardInline; } here is c# code – Sutrasno Andre Wibowo May 03 '18 at 02:36
  • [i see from here] https://stackoverflow.com/questions/39884961/create-dynamic-keyboard-telegram-bot-in-c-sharp-mrroundrobin-api – Sutrasno Andre Wibowo May 03 '18 at 02:37

0 Answers0