Click here to Skip to main content
15,892,072 members
Home / Discussions / C#
   

C#

 
QuestionHow to load different aspx web page based on browser? Pin
RagsGangwar31-Mar-15 6:14
RagsGangwar31-Mar-15 6:14 
AnswerRe: How to load different aspx web page based on browser? Pin
walterhevedeich31-Mar-15 7:04
professionalwalterhevedeich31-Mar-15 7:04 
QuestionSimultaneous File Access Causing App Freeze Pin
MadDashCoder31-Mar-15 4:06
MadDashCoder31-Mar-15 4:06 
AnswerRe: Simultaneous File Access Causing App Freeze Pin
Dave Kreskowiak31-Mar-15 5:11
mveDave Kreskowiak31-Mar-15 5:11 
GeneralRe: Simultaneous File Access Causing App Freeze Pin
MadDashCoder31-Mar-15 5:49
MadDashCoder31-Mar-15 5:49 
GeneralRe: Simultaneous File Access Causing App Freeze Pin
Pete O'Hanlon31-Mar-15 6:03
mvePete O'Hanlon31-Mar-15 6:03 
GeneralRe: Simultaneous File Access Causing App Freeze Pin
Eddy Vluggen31-Mar-15 7:29
professionalEddy Vluggen31-Mar-15 7:29 
Questiontrying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 3:51
Member 1157009831-Mar-15 3:51 
I have some sample code I cannot get to work. I think its because I'm tired. I am trying to send strings from a randomly generated text file. The goal is to find the lowest random # representative string. I have sent the strings as arguments to a method that is supposed to loop through the text file and see if there is a match and when the string is found display it in a rich text file. When I do this with a messagebox it works fine displaying the correct order of argument matches with text string matches in the loop however when I try to send it straight to the textbox it returns the last match. I know this is a silly way to do this but I cannot use an array or assign variables to the # or use an array.
C#
 private void smallBtn_Click(object sender, EventArgs e)
        {
            FindSmall("1"); FindSmall("2"); FindSmall("3"); FindSmall("4"); FindSmall("5"); FindSmall("6"); FindSmall("7"); FindSmall("8"); FindSmall("9"); FindSmall("10"); FindSmall("11"); FindSmall("12"); FindSmall("13"); FindSmall("14"); FindSmall("15"); FindSmall("16"); FindSmall("17"); FindSmall("18"); FindSmall("19"); FindSmall("20"); FindSmall("21"); FindSmall("22"); FindSmall("23"); FindSmall("24"); FindSmall("25"); FindSmall("26"); FindSmall("27"); FindSmall("28"); FindSmall("29"); FindSmall("30");
FindSmall("31"); FindSmall("32"); FindSmall("33"); FindSmall("34"); FindSmall("35"); FindSmall("36"); FindSmall("37"); FindSmall("38"); FindSmall("39"); FindSmall("40");
        }
        private void FindSmall(string searchKey1)
        {<br />
            string path = @"C:Random # File.txt";
            StreamReader sr = new StreamReader(path);
            for (int k = 0; k < 20; k++)
            {
                if (sr.ReadLine().Equals(searchKey1))
                {
                   //   MessageBox.Show(searchKey1);
                    richTextBox1.Text = "The smallest Number is: " + searchKey1.ToString();
                    break;
                }

AnswerRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 4:29
mveOriginalGriff31-Mar-15 4:29 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 4:32
Member 1157009831-Mar-15 4:32 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 4:37
Member 1157009831-Mar-15 4:37 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 4:47
mveOriginalGriff31-Mar-15 4:47 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 4:57
Member 1157009831-Mar-15 4:57 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 4:59
mveOriginalGriff31-Mar-15 4:59 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 5:03
Member 1157009831-Mar-15 5:03 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 5:10
mveOriginalGriff31-Mar-15 5:10 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 6:23
Member 1157009831-Mar-15 6:23 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 6:36
mveOriginalGriff31-Mar-15 6:36 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 6:48
Member 1157009831-Mar-15 6:48 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 7:15
Member 1157009831-Mar-15 7:15 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 8:10
mveOriginalGriff31-Mar-15 8:10 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 8:28
Member 1157009831-Mar-15 8:28 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 8:45
mveOriginalGriff31-Mar-15 8:45 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 15:27
Member 1157009831-Mar-15 15:27 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 22:00
mveOriginalGriff31-Mar-15 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.