Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8100159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:40:13+00:00 2026-06-05T22:40:13+00:00

Hey all i am in need of some help getting my code working correctly

  • 0

Hey all i am in need of some help getting my code working correctly like i am needing it to. Below is my code that when the user click on the textbox, it pops up a keyboard where they can click on any letter and it will type that letter into the textbox. Problem being is i can not seem to get the name of the text box to return so that it knows where to send the letters to.

Order in firing is:

TextBox1_MouseDown

keyboardOrPad.runKeyboardOrPad

kbOrPad.keyboardPadType

ClickLetters

Form1.putIntoTextBox

Form1

Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
    Call keyboardOrPad.runKeyboardOrPad("SHOW") 'Just shows the keyboard
    Call kbOrPad.keyboardPadType("PAD", TextBox1)
End Sub

Public Sub putIntoTextBox(ByRef what2Put As String, ByRef whatBox As TextBox)
    whatBox.Text = what2Put '<-- has error Object reference not set to an instance of an object. for the whatBox.text
End Sub

kbOrPad class

Dim theBoxName As TextBox = Nothing

Public Sub keyboardPadType(ByRef whatType As String, ByRef boxName As TextBox)
    theBoxName = boxName '<-- shows nothing here
    Dim intX As Short = 1

    If whatType = "PAD" Then
        Do Until intX = 30
            Dim theButton() As Control = Controls.Find("Button" & intX, True)

            theButton(0).Enabled = False
            intX += 1
        Loop
    ElseIf whatType = "KEYB" Then

    End If
End Sub

Private Sub ClickLetters(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim btn As Button = CType(sender, Button)

    If btn.Text = "Backspace" Then

    Else
        Call Form1.putIntoTextBox(btn.Text, theBoxName) 'theBoxName taken from keyboardPadType
    End If
End Sub

Some visuals for you:

enter image description here
enter image description here

Pastebin code: http://pastebin.com/4ReEnJB0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:40:15+00:00Added an answer on June 5, 2026 at 10:40 pm

    make sure that theBoxName is a Module scoped variable, then I would populate it like this giving you the flexibility of implementing a shared TextBox MouseDown Handler:

    Private Sub TextBox1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        Dim tb As TextBox = CType(sender, TextBox)
    
        Call keyboardPadType("PAD", tb)
    End Sub
    

    Try something like this

    Public Class Form1
    Dim myKborPad As New kbOrPad
    
    Private Sub TextBox1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        Dim tb As TextBox = CType(sender, TextBox)
    
        Call myKborPad.keyboardPadType("PAD", tb)
    End Sub
    

    Edit Based on your PasteBin code.

    I noticed you already have an instance of your keyboardPadType declared in your Module, use that instead of what I said earlier. That code should look like:

    remove:
    Dim myKborPad As New kbOrPad

    and use the theKbOrPad that you created in your module like this:

    Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        Dim tb As TextBox = CType(sender, TextBox)
    
        Call keyboardOrPad.runKeyboardOrPad("SHOW")
        Call theKbOrPad.keyboardPadType("PAD", tb)
        'Call kbOrPad.keyboardPadType("PAD", tb)
    End Sub
    

    Also about the current error your are getting, you are trying to use the default instance of your Form1 , it isn’t the actual Form that you are running, you can code around this by making the method you are trying to use as shared. Like this:

    Public Shared Sub putIntoTextBox(ByRef what2Put As String, ByRef whatBox As TextBox)
        whatBox.Text = what2Put
    End Sub
    

    But however I would actually prefer to put it into your Module like this

    Public Sub putIntoTextBox(ByRef what2Put As String, ByRef whatBox As TextBox)
        whatBox.Text = what2Put
    End Sub
    

    and call it like this

    Call putIntoTextBox(btn.Text, theBoxName)
    

    after making above changes your code worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys! I need some help writing a code that creates an array in
Hey all i am in need of some help trying to figure out how
Hey all, i am in need of some help with keeping an image aspect
Hey all, i am in need of some help with figuring out how to
Hey all, i am in need of some help trying to figure out why
Let us say we have some code that looks like below: @interface SomeClass :
Hey there, I need some help with some MYSQL Joins that I really don't
Hey all, i am new at everything VB.net/ASP.net so i need some help with
Hey all, i am in need of some help trying to figure out why
Hey all i am in need of some helpful tips/advice on how to go

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.