That line with As Integer may fail for reasons such as strict is on or what's in the textbox is out of range (emits Type Mismatch.)
You omitted what error you are seeing so I can't offer much more. Read this tutorial now: https://www.oreilly.com/library/view/vbnet-language-in/0596003080/re73.html