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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:42:23+00:00 2026-05-14T04:42:23+00:00

I’m doing a project. I’m not going to details but I will simplify my

  • 0

I’m doing a project. I’m not going to details but I will simplify my idea. I’m using Morse Code ( dot and dash) and I have 2 methods: convert_MorseToChar() and Convert_MorseTonum(). In the convert_MorseToChar() method there is a switch to compare the input from a user which will be Morse codes and mapping it to characters:

  private String convert_MorseToChar(ref string Ch) 
  {
    switch (Ch)
        {
        Case ".-":
            MorsetoChar = "a"
            break;
        Case "-...":
            MorsetoChar = "b"
            break;
        Case "-.-.":
            MorsetoChar = "c"
            break;
        Case "-..":
            MorsetoChar = "d"
            break;
        Case ".":
            MorsetoChar = "e"
            break;
        }
   }

and the other method Convert_MorseToNum(), ues the SAME combinations of Morse codes but mapping them to numbers:

  private String Convert_MorseToNum(ref string Ch) 
  {
    switch (Ch)
        {
        Case ".-":
            MorsetoChar = "1"
            break;
        Case "-...":
            MorsetoChar = "2"
            break;
        Case "-.-.":
            MorsetoChar = "3"
            break;
        Case "-..":
            MorsetoChar = "4"
            break;
        Case ".":
            MorsetoChar = "5"
            break;
        }
   }

Now the senario is: there are 2 Textbox, one the user will write Morse codes in it and the other is for the output. The user will write dot . and dash - from the keyboard and press Enter then the program will go to ONE of the 2 methods to convert the Morse codes. Now what tells the program where to go to convert?

my question is: I want to create mode key to switch between 2 modes: MorseToChar and MorseToNum. I want the down arrow key to act like a mode. When a user presses the down arrow then it the program will be in MorseToChar mode, whenever the user input the program directly use the method convert_MorseToChar to convert to characters. When the user press the down arrow again, the program will switch to MorseToNum mode here when ever the user input as morsecode, the program will directly use the method Convert_MorseToNum() to convert to numbers. How can I do that?

Please excuse my English, English is not my native language 🙂

  • 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-14T04:42:23+00:00Added an answer on May 14, 2026 at 4:42 am

    You can consume the KeyDown event. If the pressed key is the down arrow, you switch modes:

    private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
        // Determine whether the keystroke is the down arrow.
        if (e.KeyCode == Keys.Down)
        {
            charMode = !charMode;
        }
    }
    

    Of course you will have to define your charMode as a bool. And when calling your conversion method, you will check its value.

    private String Convert_Morse(ref string Ch) 
    {
        if (charMode) return convert_MorseToChar(Ch)
        else
        return convert_MorseToNum(Ch);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.