My A-Level programming project is unfortunately in vb.net
.
I remembered that InputBox
was a method, so I tried it. It came back as undeclared.
Eventually I found a forum where someone mentioned that if you import the Microsoft.VisualBasic
namespace you can use it again, but apparently that's been removed aswell ('InputBox' is not a member of 'Microsoft.VisualBasic'
).
I'm lost as to why Microsoft decided to remove InputBox
, but keep MessageBox
seeing as though they're both as useful as each other - even for a language as old as VB.
To get round this, would I create a form dedicated to collecting user inputs? There must be an better way to get InputBox
back, I just can't seem to find it.
Thank you.
Edit for replication of my error:
'create a normal forms app (I'm using .NET Core 3.0)
Public Class frmExample
Private Sub frmExample_Load(sender as Object, e as EventArgs) Handles MyBase.Load
Dim userInput as string
userInput = Interaction.InputBox("Example") 'InputBox is not a member of Interaction
userInput = Microsoft.VisualBasic.InputBox("Example") 'InputBox is not a member of Microsoft.VisualBasic
End Sub
End Class
In .NET Core 3.0
InputBox is not a method. This works as expected, however, in .NET Core 5.0
.
In order to fix this: Change your Target Framework
in Project Properties to .NET Core 5.0
.
Or alternatively do what @Jimi suggested which was to simply create an InputBox form yourself.