CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 1999
    Location
    southern England
    Posts
    24

    making convertion of characters to ascii , Hex , Decimal

    i have designed a dialog window in Visual C++ MFC
    and i want to change my characters in my edit box IDC_CHARACTER m_strChar into ASCII then HEX and then Decimal has anyone got ideas how to do this and some help with the code would be great.
    as i seemed to have hit a real wall.
    many thanks
    S


  2. #2
    Join Date
    Aug 1999
    Posts
    33

    Re: making convertion of characters to ascii , Hex , Decimal

    You can use the function like this and you can change it to realize the convertion of the HEX and the Decimal.
    CString CConvertDlg::ConvertToAscii(CString s)
    {
    CString sTemp;
    char ch;
    CString sTmp;
    for (int i=0;i<s.GetLength();i++)
    {
    ch=s.GetAt(i);
    sTmp=sTemp;
    sTemp.Format("%s%d",sTmp,int(ch));
    }
    return sTemp;
    }
    then you can invoke this function like this
    void CConvertDlg::OnConvertBtn()
    {
    CEdit * pEdit=(CEdit*)GetDlgItem(IDC_CHARACTER);
    CString sText;
    pEdit->GetWindowText(sText);
    sText=ConvertToAscii(sText);
    pEdit->SetWindowText(sText);
    return;
    }
    Good luck



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