CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Join Date
    Dec 2008
    Posts
    9

    Re: Button functions

    void CU6b82Dlg::OnDemo()

    {
    UpdateData (TRUE);


    {

    m_Sequence="BBB";

    m_Sequence2="AAA";

    m_Sequence3="CDEF";

    m_Sequence4="abcde";



    }
    UpdateData (FALSE);
    }


    this is how it appears if the button had a single function...

    however I need to make it so when demo is pressed again this firstly clears then a new set of letter appears in the sequences

  2. #17
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Button functions

    Ah, so you want to move data from one edit to another. Then, it should be like this:
    Code:
    void CU6b82Dlg::OnDemo()
    {
       // take data from controls into variables
       UpdateData (TRUE);
    
       CString sequence;
    
       // this is just an example
       switch(rand() % 5)
       {
        case 1: sequence="AAA"; break;
        case 2: sequence="BBB"; break;
        case 3: sequence="CCC"; break;
        case 4: sequence="DDD"; break;
       }
    
       // swap data
       m_Sequence5 = m_Sequence4;
       m_Sequence4 = m_Sequence3;
       m_Sequence3 = m_Sequence2;
       m_Sequence2 = m_Sequence1;
       m_Sequence5 = sequence;
    
       // put data in controls from variables
       UpdateData (FALSE);
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #18
    Join Date
    Dec 2008
    Posts
    9

    Re: Button functions

    Quote Originally Posted by cilu View Post
    Ah, so you want to move data from one edit to another. Then, it should be like this:
    Code:
    void CU6b82Dlg::OnDemo()
    {
       // take data from controls into variables
       UpdateData (TRUE);
    
       CString sequence;
    
       // this is just an example
       switch(rand() % 5)
       {
        case 1: sequence="AAA"; break;
        case 2: sequence="BBB"; break;
        case 3: sequence="CCC"; break;
        case 4: sequence="DDD"; break;
       }
    
       // swap data
       m_Sequence5 = m_Sequence4;
       m_Sequence4 = m_Sequence3;
       m_Sequence3 = m_Sequence2;
       m_Sequence2 = m_Sequence1;
       m_Sequence5 = sequence;
    
       // put data in controls from variables
       UpdateData (FALSE);
    }
    I think you have got me confused i simply want a way to get my button to but in information of my choice. It can be anything. But for example the first click will put letters into all four edit boxes

    eg

    m_Sequence "AAAA"
    m_Sequence2"BBBB"
    m_Sequence3"CCCC"
    m_Sequence4"DDDD"

    then if i press demo again it will replace these with for example

    m_Sequence "ADAD"
    m_Sequence2"ADCA"
    m_Sequence3"AGEB"
    m_Sequence4"CGEBA"

    I simply need to know how when a button is pressed more than once/numerous times, how I set up this function

  4. #19
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Button functions

    I think we already gave you enough information to make this work. Here is something more. You should be able to use it:
    Code:
    void CU6b82Dlg::OnDemo()
    {
       switch(m_State)
       {
        case 0:
            // do something
            break;
        case 1:
            // do something
            break;
        case 2:
            // do something
            break;
        case 3:
            // do something
            break;
        case 4:
            // do something
            break;
       }
    
        m_State++;
        m_State %= 5;
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured