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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:41:17+00:00 2026-05-26T12:41:17+00:00

Hey everyone I am currently getting the next variable based on if a file

  • 0

Hey everyone I am currently getting the next variable based on if a file exists, but know there must be an easier way. This thread Iterating through the Alphabet – C# a-caz gave me some good insight, but I am having a bit of a problem Implementing it with what I have. Any suggestions would be really appreciated. Thanks

//Generate Motor Spacer Part Number
textBox3.Text = "MLB028A-MTRSPR-" + "z" + "-" + "y";
if (comboBox3.Text == "28mm (NEMA 11)") textBox3.Text = textBox3.Text.Replace("z", "B");
if (comboBox3.Text == "28mm (NEMA 11)") textBox3.Text = textBox3.Text.Replace("y", "A");

//Generate Motor Spacer Part Descriptions
textBox5.Text = "SPACER, " + comboBox3.Text + ", CFG-" + "y" + " MLB028";
if (comboBox3.Text == "28mm (NEMA 11)") textBox5.Text = textBox5.Text.Replace("y", "A");

string B = @"C:\Engineering\Engineering\SW Automation\Linear Actuator Technology\MLC Series\Models\MLB028Z-MTRSPR-B-A.SLDPRT";
if (File.Exists(B))
{
   testBox3.Text = textBox3.Text.Replace("y", "B");
   textBox5.Text = textBox5.Text.Replace("y", "B");
}

string C = @"C:\Engineering\Engineering\SW Automation\Linear Actuator Technology\MLC Series\Models\MLB028Z-MTRSPR-B-B.SLDPRT";
if (File.Exists(C))
{
   testBox3.Text = textBox3.Text.Replace("y", "C");
   textBox5.Text = textBox5.Text.Replace("y", "C");
}
  • 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-26T12:41:17+00:00Added an answer on May 26, 2026 at 12:41 pm

    Okay, I am not clear on what exactly you are trying to accomplish. If you are trying to populate a couple of textboxes with a value based on the first file you find in a directory with a specific file name, then try the following:

    void PopulateTextBoxes()
    {
        string format = "MLB028A-MTRSPR-B-{1}";
        string format2 = "SPACER, {0}, CFG-{1} MLB028";
        string fileName = @"C:\Engineering\Engineering\SW Automation\Linear Actuator Technology\MLC Series\Models\MLB028Z-MTRSPR-B-{1}.SLDPRT";
    
        for(string start = "A"; start != "Z"; start = GetNextBase26(start))
        {
            if(File.Exists(String.Format(fileName,start)))
            {
                textBox3.Text = String.Format(format,start);
                textBox5.Text = String.Format(format2,textBox3.Text,start);
                break;
            }
        }
    
    }
    
    // CODE FROM http://stackoverflow.com/questions/1011732/iterating-through-the-alphabet-c-sharp-a-caz
    private static string GetNextBase26(string a)
    {
        return Base26Sequence().SkipWhile(x => x != a).Skip(1).First();
    }
    
    private static IEnumerable<string> Base26Sequence()
    {
        long i = 0L;
        while (true)
            yield return Base26Encode(i++);
    }
    
    private static char[] base26Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
    private static string Base26Encode(Int64 value)
    {
        string returnValue = null;
        do
        {
            returnValue = base26Chars[value % 26] + returnValue;
            value /= 26;
        } while (value-- != 0);
        return returnValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, I am trying to run the following program, but am getting a
Hey everyone, So, I'm currently trying the implement the APNG Specification , but am
Hey everyone, I am trying to figure out a way to query my mysql
Hey everyone, some background info: In the config file for my website, I set
Hey, is there any easy way to get information when user will change time
Hey everyone, I'm currently deciding how to layout a store front. I'm very fond
Hey everyone, I'm currently trying to figure out how to play back a tone
Hey Everyone, I was wondering if there is a current class or library in
hey there everyone. so, have a c# windows form that uses crystal reports and
Hey everyone, I am getting a heap corruption error I cannot figure out. char

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.