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 8955581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:35:40+00:00 2026-06-15T14:35:40+00:00

I am using a test card and this is the output after I swiped

  • 0

I am using a test card and this is the output after I swiped the card and it is ok

enter image description here

But when I’m trying to get the data of the swiped through prompting it to messagebox this will be the output

enter image description here

How can I fix this? I am expecting the output same as the first image, and it will also be the message of the messagebox

Here is my code:

private void CreditCardProcessor_Load(object sender, EventArgs e)
        {
            KeyPreview = true;
            KeyPress += CreditCardProcessor_KeyPress;
        }
    private bool inputToLabel = true;
        private void CreditCardProcessor_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (inputToLabel)
            {
                label13.Text = label13.Text + e.KeyChar;
                e.Handled = true;

            }
            else
            {
                e.Handled = false;
            }

            MessageBox.Show(label13.Text);
        }

In short I want to run a function after swiping the card, and use its data to be use in my function. 🙂

  • 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-15T14:35:41+00:00Added an answer on June 15, 2026 at 2:35 pm

    You’ll need to be more specific with your question. From the looks of things your card scanner is operating through the keyboard buffer. (Many card scanners operate this way) This means that every character of the strip is received as a character which is why you can capture this OnKeyPress.

    If you’re wondering why you’re only seeing one character at a time it is exactly because you’re raising a message box with each character received. If you want to know when you can call a function with the whole card info using that code what you’ll need is something like:

    private bool inputToLabel = true;
    private StringBuilder cardData = new StringBuilder();
    private void CreditCardProcessor_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!inputToLabel)
                return;
    
            if (e.KeyChar == '\r')
            {
                MessageBox.Show(cardData.ToString()); // Call your method here.
            }
            else
            {
                cardData.Append(e.KeyChar);
                //label13.Text = label13.Text + e.KeyChar;
            }
            e.Handled = true;
        }
    

    Caveat: This is assuming that the card reader library is configured to terminate a card read with carriage return. (\r) You’ll need to read up, or experiment with it for settings as to whether it can/does send a terminating character to know when the card read is complete. Failing that you can watch the output string for patterns. (I.e. when the captured string ends with “??”) Though this is less optimal.

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

Sidebar

Related Questions

I'm trying to test a class using Python unittest, but the test suite seems
I'm trying to retrofit some tests using Test::More to legacy code and I've bumped
I'm writing unit tests using Test::More and Test::Output. I use Test::More to validate the
I'm trying to get a small ruby file up and running to test how
I'm trying to display user name on the next card after user logged in,
Hi I was using this article http://www.codeproject.com/Articles/152280/Online-Credit-Card-Transaction-in-ASP-NET-Using-Pa?msg=3753796#xx3753796xx to understand the PayFlow Transaction Process and
I am using activemerchant in a rails application like this ActiveMerchant::Billing::Base.mode = :test ::GATEWAY
I'm trying to use this code to test if a sample code is a
I'm trying to communicate with a SIM card using the APDUConnection with the SAT
I am trying to validate National Identity Card Number in my application. But It

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.