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

  • SEARCH
  • Home
  • 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 6768395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:04:13+00:00 2026-05-26T15:04:13+00:00

I need codes for vb.net Getkeystate Function() without using any DLL.I’m beginner for API

  • 0

I need codes for vb.net Getkeystate Function() without using any DLL.I’m beginner for API Conversion from vb to vb.net.In vb6 they using user32 DLL.In Vb.Net i need to call Getkeystate Function without that “User32.dll” function. can any one post me the codes without using dll?
Is there any way to get key state without using that dll Getkeystate function in vb.net..? if equivalent is any one know means show me that codes.that codes should be work with in .net framework.

vb:

Private Declare Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
Dim keystate As Long
keystate = GetKeyState(27)
MsgBox keystate

vb.net

Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
On Error Resume Next
Dim KeyState As Long
KeyState = GetAsyncKeyState(17)
MsgBox(KeyState
  • 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-05-26T15:04:13+00:00Added an answer on May 26, 2026 at 3:04 pm

    You either need to call the windows API or not – and I’m not sure from your question you understand what using the DLL/invoking the windows API means. User32.dll is part windows and calling a function within it is actually asking windows to perform function for you. Do you want to replace the function or merely convert the call to vb.net?

    If all you need to just convert the call to vb.net you can use a PInvoke call to the windows API.

    here’s a sample from that page:

    <DllImport("user32.dll", SetLastError := True, CharSet := CharSet.Unicode)> _
    Private Function GetKeyState (ByVal nVirtKey As KeyStates) As Short
    End Function
    
    Imports System.Windows.Forms
    Public Class MinhaNovaTextbox
        Inherits System.Windows.Forms.TextBox
    
        Dim bInserting As Boolean = True
    
        Private Declare Function GetKeyState _
            Lib "user32" (ByVal nVirtKey As Short) As Integer
    
        Public Sub New()
            MyBase.New()
            bInserting = GetKeyState(Keys.Insert)
        End Sub
    
        Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
            bInserting = GetKeyState(Keys.Insert)
            If Not bInserting Then
                Me.SelectionLength = 1
            End If
            MyBase.OnKeyPress(e)
        End Sub
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From http://php.net/manual/en/function.mcrypt-encrypt.php , I saw the following codes using AES with an IV in
We're using .NET's Guid.NewGuid() to generate activation codes and API keys currently. I wonder
I am developing an asp.net website that will need regular updates for source codes
how to send rich text message in system.net.mail need code for send a mail
I need to move .NET code to the Compact Framework. That code uses HttpUtility.UrlEncode
I need to write robust code in .NET to enable a windows service (server
I need a free code coverage tools in .NET for personal project. NCover is
I need some asp.net pagination code samples. I would like suggestions on open source
I need to know what is code compiled unit in .net. It s located
I'm currently in need of a purely managed code DirectX wrapper for .NET. While

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.