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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:18:44+00:00 2026-06-13T17:18:44+00:00

I am cycling through the contents of a two-dimensional array containing the result of

  • 0

I am cycling through the contents of a two-dimensional array containing the result of a Punnett Square calculation for gene crosses. I need to summarize the result so that the user can readily see the unique instances. I can accomplish this by putting the result into a text box, but when I try and use a ListBox to display the data, part of the information is getting lost, namely a translation of the AaBBCc type data to something that directly relates to the traits that the user initially selected.

This is the main block of code for the operation:

    foreach (string strCombination in arrUniqueCombinations)
    {
        int intUniqueCount = 0;
        decimal decPercentage;
        foreach (string strCrossResult in arrPunnettSQ)
        {
            if (strCrossResult == strCombination)
            {
                intUniqueCount++;
            }
        }
        decPercentage = Convert.ToDecimal((intUniqueCount*100)) / Convert.ToDecimal(intPossibleCombinations);
        txtReport.AppendText(strCombination + " appears " + intUniqueCount.ToString() + " times or " + decPercentage.ToString() + "%."+ Environment.NewLine);

        lstCrossResult.Items.Add(DecodeGenome(strCombination) + " appears " + intUniqueCount.ToString() + " times or " + decPercentage.ToString() + "%.");
    }

For appending the data to the textbox I use this code and it works perfectly:

txtReport.AppendText(DecodeGenome(strCombination) + " appears " + intUniqueCount.ToString() + " times or " + decPercentage.ToString() + "%."+ Environment.NewLine);

Giving the result:
Trait 1 Het.,Trait 3 appears 16 times or 25%.

For adding the result to a list box, this works:

lstCrossResult.Items.Add(strCombination + " appears " + intUniqueCount.ToString() + " times or " + decPercentage.ToString() + "%.");

Giving the result:
AaBBCc appears 16 times or 25%.

But the contents of strCombination is AaBBCc and I need it translated to “Trait 1 Het.,Trait 3”, which I accomplish with this bit of code:

private string DecodeGenome(string strGenome)
{
    string strTranslation = "";
    int intLength = strGenome.Length;
    int intCounter = intLength / 2;
    string[] arrPairs = new string[intLength / 2];


    //Break out trait pairs and load into array

    for (int i = 1; i <= intLength; i++)
    {
        arrPairs[i / 2] = strGenome.Substring((i-1),2);
        i++;
    }

    foreach (string strPair in arrPairs)
    {
        char chFirstLetter = strPair[0];
        char chSecondLetter = strPair[1];
        intCounter = intCounter - 1;

        if (Char.IsUpper(chFirstLetter))
        {
            if (!Char.IsUpper(chSecondLetter))
            {
                if (intCounter > 0)
                {
                    txtReport.AppendText(GetDescription(strPair.Substring(0, 1)) + " Het.,");
                }
                else
                {
                    txtReport.AppendText(GetDescription(strPair.Substring(0, 1)));
                }
            }
        }
        else
        {
            if (!Char.IsUpper(chSecondLetter))
            {
                if (intCounter > 0)
                {
                    txtReport.AppendText(GetDescription(strPair.Substring(0, 1)) + ",");
                }
                else
                {
                    txtReport.AppendText(GetDescription(strPair.Substring(0, 1)));
                }
            }

        }

    }

    return strTranslation;
}

That has no problem displaying in a text box, but when I try and put it as an item into a list box it turns it into null. Instead of:
“Trait 1 Het.,Trait 3 appears 16 times or 25%.”
I get:
” appears 16 times or 25%.”

I have tried adding the results to an ArrayList, then populating the listbox after everything is processed, but the result is the same.

Any clues as to why the list box is not accepting the translated AaBBCc information would be greatly appreciated.

  • 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-13T17:18:46+00:00Added an answer on June 13, 2026 at 5:18 pm

    strTranslation is never set. Everything is pushed to txtReport.AppendText

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

Sidebar

Related Questions

I need to get a list of steps which jquery will be cycling through
I'm cycling through an array and adding up a figure. I have a value
Problem - instead of cycling through the images in the array, it jumps right
I need help with cycling through nodes of a XML document using XmlTextReader. Using
When one of my sprites is being dragged (moved around), I'm cycling through other
I am learning JQuery and trying to create cycling text through images but I
I'm creating thumbnails cycling through a lot of images, when I find a large
When cycling through statements entered to the console, I occasionally find that the text
I want to invoke methods with a certain attribute. So I'm cycling through all
I'm cycling through several different attributes looking for something not set to To do

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.