Click here to Skip to main content
15,917,588 members
Home / Discussions / C#
   

C#

 
GeneralRe: Updating the password handling Pin
Reiss16-Nov-11 2:57
professionalReiss16-Nov-11 2:57 
GeneralRe: Updating the password handling Pin
Peter_in_278016-Nov-11 9:53
professionalPeter_in_278016-Nov-11 9:53 
GeneralRe: Updating the password handling Pin
Bernhard Hiller16-Nov-11 21:45
Bernhard Hiller16-Nov-11 21:45 
AnswerRe: Updating the password handling Pin
BobJanova16-Nov-11 3:04
BobJanova16-Nov-11 3:04 
AnswerRe: Updating the password handling Pin
Luc Pattyn16-Nov-11 4:03
sitebuilderLuc Pattyn16-Nov-11 4:03 
GeneralRe: Updating the password handling Pin
Peter_in_278016-Nov-11 10:02
professionalPeter_in_278016-Nov-11 10:02 
GeneralRe: Updating the password handling Pin
Bernhard Hiller16-Nov-11 23:02
Bernhard Hiller16-Nov-11 23:02 
QuestionReading next block of data on button click event Pin
MumbleB15-Nov-11 18:55
MumbleB15-Nov-11 18:55 
Hi Guys and ladies. I am reading a record into a windows form which works fine. The record structure is: Header details of 463 chars and then a repetative set of records of 276 chars each. Problem is that the string can have anything between 1 and a max of 50 repetative records. On clicking the next button i am trying to display the details from the second record etc. I am trying to figure out how to best acieve this as if I click the button the first time it reads the second block of data fine, if I click it again it reads the second block again instead of reading the third bloack of data.

How do I read the data to be able to get to the third record? Would it be best to load the blocks into a dataset and then maybe read that? Below is the code I currently have.

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
    this.Dispose();
    this.Close();
}

private void button2_Click(object sender, EventArgs e)
{
    filepath = txtFileName.Text;
    StreamReader sr = new StreamReader(filepath);
    string holdLine = sr.ReadLine();
    int recLength = holdLine.Length;
    int startIndex = 463;
    int oneRecLength = 276;
    int totalRecs = (recLength - startIndex) / oneRecLength;
    int startread = 739;
    int lastread = 0;
    if ((recLength - 463) > 1015)
    {
        if((totalRecs - 1) != 0)
        {
            string nextrec = holdLine.Substring(startread, 276);
            HOM_CO_ID = nextrec.Substring(0, 5); //= 5
            HOM_PROD_CODE = nextrec.Substring(5, 3); //= 3
            HOM_ACCT_TYPE = nextrec.Substring(8, 1); //= 1
            HOM_BRANCH = nextrec.Substring(9, 6); //= 6
            HOM_ACCOUNT_NO = nextrec.Substring(15, 23); //= 23
            HOM_BUDGET_NO = nextrec.Substring(38, 5); //= 5
            HOM_ACCOUNT_NAME = nextrec.Substring(43, 30); //= 30
            HOM_AMOUNT = nextrec.Substring(73, 17); //= 17
            HOM_REF = nextrec.Substring(90, 20); //= 20
            HOM_DESCR = nextrec.Substring(110, 47); //= 47
            HOM_TRAN_CODE = nextrec.Substring(157, 5); //= 5
            HOM_REVERSAL_DESCR = nextrec.Substring(162, 47); //= 47
            NOM_REF2 = nextrec.Substring(209, 20); //= 20
            NOM_DESCRIPTION = nextrec.Substring(229, 47); //= 47

            txtHomCompId.Text = HOM_CO_ID;
            txtHomProdCode.Text = HOM_PROD_CODE;
            txtHomAccountType.Text = HOM_ACCT_TYPE;
            txtHomBranch.Text = HOM_BRANCH;
            txtHomAccNo.Text = HOM_ACCOUNT_NO;
            txtHomBudgetNo.Text = HOM_BUDGET_NO;
            txtHomAccName.Text = HOM_ACCOUNT_NAME;
            txtHomAmount.Text = HOM_AMOUNT;
            txtHomRef.Text = HOM_REF;
            txtHomDescr.Text = HOM_DESCR;
            txtHomTranCode.Text = HOM_TRAN_CODE;
            txtHomRevDescr.Text = HOM_REVERSAL_DESCR;
            txtNomRef2.Text = NOM_REF2;
            txtNomDescr2.Text = NOM_DESCRIPTION;
            validateMessage();
            totalRecs--;
            startread = lastread + 276;
        }
    }

Excellence is doing ordinary things extraordinarily well.

AnswerRe: Reading next block of data on button click event Pin
RobCroll15-Nov-11 19:40
RobCroll15-Nov-11 19:40 
AnswerRe: Reading next block of data on button click event Pin
Wayne Gaylard15-Nov-11 19:42
professionalWayne Gaylard15-Nov-11 19:42 
AnswerRe: Reading next block of data on button click event Pin
BobJanova16-Nov-11 3:09
BobJanova16-Nov-11 3:09 
QuestionTimers & editing controls Pin
Krylosac15-Nov-11 16:35
Krylosac15-Nov-11 16:35 
AnswerRe: Timers & editing controls Pin
Wayne Gaylard15-Nov-11 17:06
professionalWayne Gaylard15-Nov-11 17:06 
GeneralRe: Timers & editing controls Pin
Krylosac15-Nov-11 17:39
Krylosac15-Nov-11 17:39 
GeneralRe: Timers & editing controls Pin
Wayne Gaylard15-Nov-11 17:53
professionalWayne Gaylard15-Nov-11 17:53 
AnswerRe: Timers & editing controls Pin
Luc Pattyn15-Nov-11 17:28
sitebuilderLuc Pattyn15-Nov-11 17:28 
GeneralRe: Timers & editing controls Pin
BobJanova16-Nov-11 3:11
BobJanova16-Nov-11 3:11 
GeneralRe: Timers & editing controls Pin
Krylosac16-Nov-11 3:24
Krylosac16-Nov-11 3:24 
AnswerRe: Timers & editing controls Pin
Not Active15-Nov-11 17:28
mentorNot Active15-Nov-11 17:28 
QuestionHow To Create Classic Menu in C# desktop apll. Pin
Devdattahack1015-Nov-11 12:27
Devdattahack1015-Nov-11 12:27 
AnswerRe: How To Create Classic Menu in C# desktop apll. Pin
PIEBALDconsult15-Nov-11 13:42
mvePIEBALDconsult15-Nov-11 13:42 
Questionc# image pixel shrink Pin
Member 773856115-Nov-11 8:43
Member 773856115-Nov-11 8:43 
AnswerRe: c# image pixel shrink Pin
Peter_in_278015-Nov-11 13:23
professionalPeter_in_278015-Nov-11 13:23 
GeneralRe: c# image pixel shrink Pin
Smithers-Jones15-Nov-11 22:23
Smithers-Jones15-Nov-11 22:23 
AnswerRe: c# image pixel shrink Pin
BillWoodruff16-Nov-11 14:54
professionalBillWoodruff16-Nov-11 14:54 

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.