Using Flags


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Using Flags

  1. #1
    Dave pie Guest

    Using Flags


    Hi.
    I am using 2 data files to get information that will be used in a 3rd file
    based on a true/false statement of promotion. EX. If promotion = false
    then step 2 becomes step three and new salary becomes 254637. My questiion
    is that how can I use a flag to get the "step" to change to the new number
    in the new file and print to the screen

    Lanes
    step junior senior analyst
    1 217400 290000 324400 #1
    2 234560 312923 345566
    3 254637 330000 998777
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    Name Soc.Sec.# lane step promotion #2
    Sue cole 433-33-3432 1 2 false
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    Name Soc,Sec# New Title New Step New Salary #3

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    This is what I have so far.


    Dim sched(1 To 4, 1 To 4) As Integer, step As Single, jun As Single, sen
    As Single
    Dim ana As Single, s As Single
    Dim person(1 To 7, 1 To 5) As String, ss As String, lane As Single
    Dim up As Single, promo As String
    Dim i As Integer
    Dim proFlag As Boolean, newSalary As Single



    Private Sub cmdDisplay_Click()
    Dim name As String
    promo = proFlag
    picOutput.Print "Step"; Tab(16); "Junior"; Tab(30); "Senior"; Tab(44); "Systems"
    picOutput.Print Tab(14); "Programmer"; Tab(28); "Programmer"; Tab(44);
    "Analyst"
    picOutput.Print
    Open "A:\SCHEDULE.TXT" For Input As #1
    For i = 1 To 4
    Input #1, step, jun, sen, ana


    picOutput.Print step, jun, sen, ana
    Next i


    Close #1
    picOutput.Print
    picOutput.Print
    picOutput.Print
    picOutput.Print "Name"; Tab(24); "Soc. Sec.#"; Tab(42); "Lane"; Tab(56);
    _
    "Step"; Tab(71); "Promotion"
    picOutput.Print
    Open "A:\Personnel.txt" For Input As #2
    For i = 1 To 7
    Input #2, name, ss, lane, up, promo
    picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56); up;
    _
    Tab(71); promo
    Next i
    Close #2


    End Sub

    Private Sub ShowData()

    End Sub

    THANKS


  2. #2
    Kathleen Dollard-Joeris Guest

    Re: Using Flags

    Dave,

    I may be missing something. Is it as simple as the following?

    > Open "A:\Personnel.txt" For Input As #2
    > For i = 1 To 7
    > Input #2, name, ss, lane, up, promo

    * if promo then
    * up = up + 1
    * endif
    > picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56);

    up;
    > _
    > Tab(71); promo
    > Next i


    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --



  3. #3
    Dave pie Guest

    Re: Using Flags


    Hi Kathleen;

    I son't think I explained this good enough. If the promo = false then sthe
    step increases by1 and the salary(lanes in file #1) also moves to the next
    line down. My problem is that I don't yet know how to code a flag to make
    those two things happen (and maybe don't even know how to explain it :-)
    If there is no promotion the person moves to the next step in their respective
    lane (file #1) and their salary is increased. Something like:



    "Kathleen Dollard-Joeris" <kjoeris@noemailplease.com> wrote:
    >Dave,
    >
    >I may be missing something. Is it as simple as the following?
    >
    >> Open "A:\Personnel.txt" For Input As #2
    >> For i = 1 To 7
    >> Input #2, name, ss, lane, up, promo

    >* if promo then
    >* up = up + 1
    >* endif
    >> picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56);

    >up;
    >> _
    >> Tab(71); promo
    >> Next i

    >
    >--
    >Kathleen
    >(MS-MVP)
    >Reply in the newsgroup so everyone can benefit
    >--
    >
    >



  4. #4
    Dave pie Guest

    Re: Using Flags



    Sorry! I hit the wrong key.
    Something like:

    If promo = false Then

    step = step + 1 and newSalry =(?)
    "Dave pie" <piekar65@hotmail.com> wrote:
    >
    >Hi Kathleen;
    >
    >I son't think I explained this good enough. If the promo = false then sthe
    >step increases by1 and the salary(lanes in file #1) also moves to the next
    >line down. My problem is that I don't yet know how to code a flag to make
    >those two things happen (and maybe don't even know how to explain it :-)
    >If there is no promotion the person moves to the next step in their respective
    >lane (file #1) and their salary is increased. Something like:
    >
    >
    >
    >"Kathleen Dollard-Joeris" <kjoeris@noemailplease.com> wrote:
    >>Dave,
    >>
    >>I may be missing something. Is it as simple as the following?
    >>
    >>> Open "A:\Personnel.txt" For Input As #2
    >>> For i = 1 To 7
    >>> Input #2, name, ss, lane, up, promo

    >>* if promo then
    >>* up = up + 1
    >>* endif
    >>> picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56);

    >>up;
    >>> _
    >>> Tab(71); promo
    >>> Next i

    >>
    >>--
    >>Kathleen
    >>(MS-MVP)
    >>Reply in the newsgroup so everyone can benefit
    >>--
    >>
    >>

    >



  5. #5
    Kathleen Dollard-Joeris Guest

    Re: Using Flags

    Dave,

    I am still struggling to figure out where you problem lies. Why not just
    make each column in your output an array. I starred the lines I changed. I
    don't get the jun/sen distinction.

    Private Sub cmdDisplay_Click()
    Dim name As String
    *Dim Jun(1 to 4) as single
    *Dim Sen(1 to 4) as single

    promo = proFlag
    picOutput.Print "Step"; Tab(16); "Junior"; Tab(30); "Senior"; Tab(44);
    "Systems"
    picOutput.Print Tab(14); "Programmer"; Tab(28); "Programmer";
    Tab(44);
    "Analyst"
    picOutput.Print
    Open "A:\SCHEDULE.TXT" For Input As #1
    For i = 1 To 4
    * Input #1, step, jun(i), sen(i), ana


    * picOutput.Print step, jun(i), sen(i), ana
    Next i


    Close #1
    picOutput.Print
    picOutput.Print
    picOutput.Print
    picOutput.Print "Name"; Tab(24); "Soc. Sec.#"; Tab(42); "Lane";
    Tab(56);
    _
    "Step"; Tab(71); "Promotion"
    picOutput.Print
    Open "A:\Personnel.txt" For Input As #2
    For i = 1 To 7
    Input #2, name, ss, lane, up, promo
    * if not promo then
    * up = up + 1
    * NewSalary = jun(up) ' I don't know how you figure jun/sen
    * endif
    picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56); up;
    _
    Tab(71); promo
    Next i
    Close #2


    End Sub

    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --



  6. #6
    Kathleen Dollard-Joeris Guest

    Re: Using Flags

    Dave,

    Also, look into using FreeFile instead of hard coding the file numbers.

    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --



  7. #7
    Dave pie Guest

    Re: Using Flags


    Hi:
    I thought that my intial information wasn't enough to get the answer I need
    but in recognizing that those of you who answer our questions have other
    lives also, I didn't want you to have to scroll and scroll reading everything
    I guess I will try to make this mor discernible.

    I'm writing a program that processes current personnel records on file PERSONNEL.TX
    to output a Salary Budget for next year. The current salary is read in from
    SALARY.TXT. THE personnel.txt looks like this:

    NAME Soc.SEC.# Lane Step Promotion
    Sue Doe Code 473-23-4567 1 1 False
    Elmer Dowhile 893-44-5432 1 3 True
    etc...in a (1 to 9, 1 to 3) array

    The Salary.TXT looks like this:

    step Junior(Jen) Senior(Sen) Systems
    Programmer Programmer Analyst
    1 21740 29000 32400
    2 24300 31900 35500
    etc..(1 to 4, 1 to 4)

    The Salary Budget should look like this:
    Name Soc.Sec# New New New
    Title Step Salary
    Sue Doe Code 435-44-3334 Junior 2 24300

    If there is no promotion the employee moves to the next step an salary increases
    accordingly. If there is a promotion, then they move to the next lane and
    salary increases accordingly. So it really all hinges on the promotion factor.
    I want the budget to change in line with the promotion and I think I should
    be able to do that with some kind of flag but lack the knowledge to code
    it. If you can help, PLEASE do.
    Thanks

    Dim sched(1 To 4, 1 To 4) As Integer, step As Single, jun As Single, sen
    As Single
    Dim ana As Single, s As Single
    Dim person(1 To 7, 1 To 5) As String, ss As String, lane As Single
    Dim up As Single, promo As String
    Dim i As Integer
    Dim proFlag As Boolean, newSalary As Single



    Private Sub cmdDisplay_Click()
    Dim name As String
    promo = proFlag
    picOutput.Print "Step"; Tab(16); "Junior"; Tab(30); "Senior"; Tab(44); "Systems"
    picOutput.Print Tab(14); "Programmer"; Tab(28); "Programmer"; Tab(44);
    "Analyst"
    picOutput.Print
    Open "A:\SCHEDULE.TXT" For Input As #1
    For i = 1 To 4
    Input #1, step, jun, sen, ana

    picOutput.Print step, jun, sen, ana
    Next i


    Close #1
    picOutput.Print
    picOutput.Print
    picOutput.Print
    picOutput.Print "Name"; Tab(24); "Soc. Sec.#"; Tab(42); "Lane"; Tab(56);
    _
    "Step"; Tab(71); "Promotion"
    picOutput.Print
    Open "A:\Personnel.txt" For Input As #2
    For i = 1 To 7
    Input #2, name, ss, lane, up, promo
    picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56); up;
    _
    Tab(71); promo
    Next i
    Close #2


    End Sub

    "Kathleen Dollard-Joeris" <kjoeris@noemailplease.com> wrote:
    >Dave,
    >
    >I am still struggling to figure out where you problem lies. Why not just
    >make each column in your output an array. I starred the lines I changed.

    I
    >don't get the jun/sen distinction.
    >
    >Private Sub cmdDisplay_Click()
    > Dim name As String
    >*Dim Jun(1 to 4) as single
    >*Dim Sen(1 to 4) as single
    >
    > promo = proFlag
    >picOutput.Print "Step"; Tab(16); "Junior"; Tab(30); "Senior"; Tab(44);
    >"Systems"
    > picOutput.Print Tab(14); "Programmer"; Tab(28); "Programmer";
    >Tab(44);
    >"Analyst"
    > picOutput.Print
    > Open "A:\SCHEDULE.TXT" For Input As #1
    > For i = 1 To 4
    >* Input #1, step, jun(i), sen(i), ana
    >
    >
    >* picOutput.Print step, jun(i), sen(i), ana
    > Next i
    >
    >
    > Close #1
    > picOutput.Print
    > picOutput.Print
    > picOutput.Print
    > picOutput.Print "Name"; Tab(24); "Soc. Sec.#"; Tab(42); "Lane";
    >Tab(56);
    >_
    > "Step"; Tab(71); "Promotion"
    > picOutput.Print
    > Open "A:\Personnel.txt" For Input As #2
    > For i = 1 To 7
    > Input #2, name, ss, lane, up, promo
    >* if not promo then
    >* up = up + 1
    >* NewSalary = jun(up) ' I don't know how you figure jun/sen
    >* endif
    > picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56);

    up;
    >_
    > Tab(71); promo
    > Next i
    > Close #2
    >
    >
    >End Sub
    >
    >--
    >Kathleen
    >(MS-MVP)
    >Reply in the newsgroup so everyone can benefit
    >--
    >
    >



  8. #8
    Kathleen Dollard-Joeris Guest

    Re: Using Flags

    Dave,

    Sorry it took a couple days to get back to you. The real world has been
    intruding.


    > If there is no promotion the employee moves to the next step an salary

    increases
    > accordingly. If there is a promotion, then they move to the next lane and
    > salary increases accordingly. So it really all hinges on the promotion

    factor.
    > I want the budget to change in line with the promotion and I think I

    should
    > be able to do that with some kind of flag but lack the knowledge to code


    If I understand you and up is actually step then

    > Input #2, name, ss, lane, up, promo

    ' Print current status
    > picOutput.Print name; Tab(24); ss; Tab(42); lane; Tab(56);

    up;
    if promo then
    lane = lane + 1
    else
    up = up + 1
    endif
    ' Print new status - you work out the header
    picoutput.print name; tab(24);ss;tab*42);
    lane;tab(56);up;tab(70);asched(up,lane)

    You also need to dim your schedule array as Long instead of Integer.

    So, after you fiddle with the above, how does it differ from what you need?
    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center