Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Trupti Mehta

@Trupti Mehta
About
Posts
107
Topics
36
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problem Reading, Saving from Excel file
    T Trupti Mehta

    Hello, I have to read an Excel file, update some data and save the file. I wrote small code to open, read, save and close an excel file. I am using Microsoft.Office.Interop to achieve the goal. I have set the Excel application visibility as false. I tried the same in C# and VB.NET, but am facing same problem. Code is below:-

    Private Sub OpenFile()
        Try
            excelApp = New Excel.ApplicationClass()
            excelApp.Visible = False
            excelworkbook = excelApp.Workbooks.Open(workbookPath, 0, False, 5, "", "", False, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", True, False, 0, False, False, False)
            excelSheets = excelworkbook.Worksheets
            excelWorkSheet = excelworkbook.Worksheets("Sheet1")  
            MessageBox.Show("Connected and Opened")
            range = excelWorkSheet.UsedRange
            MsgBox("Rows = " + range.Rows.Count.ToString + " Cols = " + range.Columns.Count.ToString)
        Catch e As Exception
            excelSheets = Nothing
            excelworkbook = Nothing
            excelWorkSheet = Nothing
            excelApp = Nothing
            MessageBox.Show("Exception MSG " + e.Message + "\\n ST :" + e.StackTrace)
        End Try
    End Sub
    
    Private Function ReadRow(ByVal rowNo As Integer, ByVal startRange As String, ByVal endRange As String) As Array
        Dim rge As Excel.Range = Nothing
        Dim valuesList As Array = Nothing
    
        Try
            rge = excelWorkSheet.Range(startRange, endRange)
            valuesList = rge.Cells.Value
        Catch e As Exception
            MsgBox("Uable To Read from " + startRange + " To " + endRange + " Due to " + vbCrLf + e.StackTrace)
            Save\_Close()
        End Try
    
        Return valuesList
    End Function
    
    Private Sub Save\_Close()
        Try
            excelworkbook.Save()
            excelworkbook.Close()
        Catch ee As Exception
            MessageBox.Show("Unable To Save : " + ee.Message)
            excelworkbook.Close()
        End Try
    
        releaseObject(excelApp)
        releaseObject(excelworkbook)
        releaseObject(excelWorkSheet)
        releaseObject(excelSheets)
    
        MessageBox.Show("File Closed")
    End Sub
    
    Private Sub releaseObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        Finally
            GC.Collect()
    
    Visual Basic csharp com data-structures help

  • Convert Fortran program to Java
    T Trupti Mehta

    Hi, I have a Fortran program which I have to convert into Java originally. I have converted the code completely but can't get appropriate resutls. The code contains lot of arithmetic calculations using double precision data type of Fortran. I believe the data types of Java are based differnt than Fortran. Fortran's double precision type is based on IEEE756. I want to know how to convert these double precision calculations into Java. For example:

    double precision d1 = 0.3648564D0;
    d1**2 // ** indicates exponent
    DSIN(d1) // sin of double precision
    DCOS(d1) // cos of double precision

    The above are my main concerns which I find very difficult to convert. I use Math.sin & cos for DSIN & DCOS. But Fortran 77 deals somthing differntly with double precision. How to convert/translate that into our java application is what I am looking for. If you can provide the same for C++ that would also be a plus for me, I will use the code accordingly of Java application. Please help me out. Am stuck up very badly.

    Thanks Terry

    Java help tutorial c++ java

  • Convert Fortran Code
    T Trupti Mehta

    Hi, I have a Fortran program which I have to convert into Java originally. I have converted the code completely but can't get appropriate resutls. The code contains lot of arithmetic calculations using double precision data type of Fortran. I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example:

    double precision d1 = 0.3648564D0;
    d1**2 // ** indicates exponent
    DSIN(d1) // sin of double precision
    DCOS(d1) // cos of double precision

    The above are my main concerns which I find very difficult to convert. I use sin & cos for DSIN & DCOS. But Fortran 77 deals somthing differntly with double precision. How to convert/translate that into our normal C++ application is what I am looking for. If you cna provide the same for Java that would be a plus for me, otherwise I will use the code accordingly of C++ in my Java application. Please help me out. Am stuck up very badly.

    Thanks Terry

    C / C++ / MFC help tutorial c++ java

  • Convert CString to int or float
    T Trupti Mehta

    Thanks CPallini, its working perfectly as expected. Got rid from all type casts. Thanks a lot to all of you trying to solve my problem.

    Thanks Terry

    C / C++ / MFC c++

  • Convert CString to int or float
    T Trupti Mehta

    Hello, Thanks. I tried the following way :

    CString csValue;
    GetDlgItem(IDC\_PRICE\_EDIT)->GetWindowText(csValue);
    

    .....
    char* dest;
    WideCharToMultiByte(CP_ACP, 0, csValue, -1, dest, 10, NULL, NULL);
    float flt = (float)atof(dest);
    CString d(_T("Converted Float:"));
    d.Format(_T("%s %.2f"), d, flt);
    AfxMessageBox(d);

    Using WideCharToMultiByte method, I put all values accordingly & converted to float using atof. I get the converted value. BUT as soon as the Converted .. msg box is displayed I also get "Assertion Failed!" :File thrdcore.cpp, Line 867 Abort/Ret/Ig. Retry or ignore doesn't respond so I have to select Abort. It points to if (m_nDisablePumpCount != 0) { TRACE0("Error: CWinThread::PumpMessage called when not permitted.\n"); --------> ASSERT(FALSE); } of PumpMessage(). Where am aI going wrong can you point out? Do I need to change anything in Wide...(). AS dest is not initialized, I get warning message for that also. I have also noted that in eVC++4 I get exceptions at Assert many times, any special reason?

    Thanks Terry

    C / C++ / MFC c++

  • CArray in CMap
    T Trupti Mehta

    Well Mihai, I also like Serilization, but EVC+ with +WinCE is giving a tough time with serialization. All proper code yet write & Read serialized objects is not supportive. So I have to take the long route. WinCE also doesn't support AfxAPI SerializeElements for CMap. If ypu can give other solution, world be really helpful.

    Thanks Terry

    C / C++ / MFC c++ data-structures help tutorial question

  • Convert CString to int or float
    T Trupti Mehta

    Thanks CPallini for your quick response. I entered your code on top of my file (after #includes) & used _tstof(csValue), but it gives me the same error for wtof. I also can't find wtof or _wtof in Help of Evc++4. wtoi is available but not wtof. TChar.h is included. error C2065: 'wtof' : undeclared identifier Any further help, please.

    Thanks Terry

    C / C++ / MFC c++

  • CArray in CMap
    T Trupti Mehta

    Hello, I use EVC++4 for ARMV4I device. I have come across a situation where I find difficult to figure out few things. I store data in a file like: 1+Oper 1+1+Dept 1+12+2+1.0+2+2.0+3.5+1+3.5 -------- ----------- - --------- --------- Obj 1 Obj 2 S Obj 3 Obj 3 S-> # of objects stored of Obj 3 type Now I am reading the file & I want data in a form where value of 1 from Obj 2 is against all the values of Obj 3. So, 1 Obj 3 Obj 3 For this I believe I should have a CArray in a CMap. The CArray can contain all Obj3 & value remains as the key of the CMap. I am not able to make out how do I declare the CArray & the CMap. I am getting errors of CArray: no operator = .... Can anyone help me create CArray & CMap respectively & also show how to add contents in the array & map rexpectively. While reading file, I might need to access the saved CArray & add more if I come across the same number again. I am using EVC so please provide only MFC or general C/C++ solutions - No std, ATL, etc. Evc doesn't support CArrayEx & CMapEx. Help is highly appreciated.

    Thanks Terry

    C / C++ / MFC c++ data-structures help tutorial question

  • CArray problem
    T Trupti Mehta

    Hi Mark, If I add objects in array like you are adding, then my code is working perfect. But I am working different way. In my GUI, I add objects in the array in my GUI CPage4 (m_page4 member var), then on Ok button I create DeptStock deptStock object & SetCStockEntryArr(m_page4.GetStockEntries()). TILL this things are fine. Then I pass deptStock to a file to store the object details in file. g_dbOperations.Write_StockTextFile(deptStock);

    // WRITE Departments MAP TO FILE
    void DbOperations::Write_StockTextFile(DeptStock deptStock) {

        .........  
    CString toWrite;
    int index = -1;
    
    OperatorDetails od = deptStock.GetOperator();
    DeptDetails dd = deptStock.GetDept();
    CArray<cstockentry,>& stockArr = deptStock.GetStockEntryArr();  // This returns 0 sizxe array
    

    // stockArr = deptStock.GetStockEntryArr();

    /* CStockEntry cse1(2.2f, 5, 10.2f);
    CStockEntry cse2(5.0f, 3, 15.0f);
    stockArr.Add(cse1);
    stockArr.Add(cse2);
    */
    CString str(_T("Stock Size:"));
    str.Format(_T("%s %d \n %s %d"), str, stockArr.GetSize(), _T("Dept Stock Arr "), deptStock.GetStockEntryArr().GetSize());
    AfxMessageBox(str); // Both DISPLAYS 0

    This is how the flow is. If I remove the above comments of adding objects od CStockEntry to stockArr, it gives proper results. But I have already added the array elements & not able to retrive. I have given a better & clear picture of the flow of my program & error point. Hope you can help me out to track the problem.

    Thanks Terry

    C / C++ / MFC c++ help data-structures

  • Convert CString to int or float
    T Trupti Mehta

    Thanks CPallini & everybody else. This solved my problem for int's but not for float as _ttof or _tstof id not defined in tchar also. I am using eVc++4.0 with WinCE 5. I can't find the functions in eVC help or tchar.h file also & it throws compilation error : error C2065: '_tstof' : undeclared identifier Any other alternative to do the above task would be great.

    Thanks Terry

    C / C++ / MFC c++

  • CArray problem
    T Trupti Mehta

    Working with EVc++4 on ARMV4I device. I have an CArray :

    CArray<CStockEntry, CStockEntry> stockArr;
    void SetCStockEntryArr(CArray<CStockEntry, CStockEntry>& arr);
    CArray<CStockEntry, CStockEntry>& GetStockEntryArr();

    in my .cpp:

    void DeptStock::SetCStockEntryArr(CArray<CStockEntry, CStockEntry>& arr) {
    for (int i=0; i <= arr.GetUpperBound(); i++) {
    CStockEntry se = arr.GetAt(i);
    this->stockArr.Add(se);
    }

    CString s1 = _T("Size of copied Array & Org:");
    s1.Format(_T("%s %d %d"), s1, stockArr.GetSize(), arr.GetSize()); // This shows same number of arr & stockArr GetSize
    AfxMessageBox(s1);

    s1.Empty();
    return;
    }

    CArray<CStockEntry, CStockEntry>& DeptStock::GetStockEntryArr() {
    CString s1 = _T("Size of Returning Array:");
    s1.Format(_T("%s %d"), s1, stockArr.GetSize()); // This shows 0 as GetSize
    AfxMessageBox(s1);

    s1.Empty();

    return this->stockArr;
    }

    In between Set & Get I don't perform any operations on the stockArr. Why is while set, it is stored properly, but while retriing I get an empty array. Any help is appreciated.

    Thanks Terry

    C / C++ / MFC c++ help data-structures

  • Convert CString to int or float
    T Trupti Mehta

    In Evc++4, I want to convert CString to int/float. I use the following code :

    // CONVERT STRING TO INT
    CString csValue;
    GetDlgItem(IDC\_OpNo\_EDIT)->GetWindowText( csValue );
    m\_opNo = atoi((char\*)(LPCTSTR)csValue);
    

    The above code works, but only with the first digit, so If I enter 34, I only get 3 in m_opNo int. same happens with float atof. Can anyone tell what changes ae required to get full digit from CString to int. Is I enter 34 I want 34 as int.

    Thanks Terry

    C / C++ / MFC c++

  • Setup & related for EVC application
    T Trupti Mehta

    Hi, I have developed an application in eVc++4 on ARMV4I device. At present the application is ready adn in testing phase. Before handing over the final version, I want to know how to do the following: 1) The user should able to start the application only once i.e. if the application is already running, the user shouldn't be able to open another time the application. 2) Create a setup for the application. I want to restrict the setup being used only 3 times. Creating shortcut on desktop will be handled with the setup. 3) Add the application in the start up. Any helpline and guidance for the above is highly appreciated.

    Thanks Terry

    C / C++ / MFC c++ testing beta-testing tutorial announcement

  • Setup & related for EVC application
    T Trupti Mehta

    Hi, I have developed an application in eVc++4 on ARMV4I device. At present the application is ready adn in testing phase. Before handing over the final version, I want to know how to do the following: 1) The user should able to start the application only once i.e. if the application is already running, the user shouldn't be able to open another time the application. 2) Create a setup for the application. I want to restrict the setup being used only 3 times. Creating shortcut on desktop will be handled with the setup. 3) Add the application in the start up. Any helpline and guidance for the above is highly appreciated.

    Thanks Terry

    Mobile c++ testing beta-testing tutorial announcement

  • Windows CE emulator
    T Trupti Mehta

    Ibrahim, You must have set your CPU of your device. From project->Settings, select WinCE Emulator from drop down or Select StandardSDK from the toolbar option & Rebuild again & then run. But doing so, the program will use standard sdk & compile & not based on Armv4i. For such CPU's got to run via device only, no other alternative. Hope this helps.

    Thanks Terry

    Mobile c++ help question

  • File I/O Permission VB2003
    T Trupti Mehta

    Hello, I am developing an Smart Device application in Vb2003. I want to store objects stored in Collection in a file. While doing the process, I get IOException on first creating FileStream. It says need to set Security for File I/O permissions. Can anyone help me, what I need to do and how do I achieve it. Any help, guidance is highly appreciated.

    Thanks Terry

    Visual Basic security help question

  • How to Set Security?
    T Trupti Mehta

    How do I set File I/O permission in my application which is devioping in Vb2003 for Win CE platform. I get IOException on opening a file.

    Thanks Terry

    Visual Basic question security tutorial

  • 0xC000001D "Fatal Application Error" ????
    T Trupti Mehta

    Afx.. was from first. Error is coming from the code attached in first message & in the mean while had also added EndDialog. Will try removing EndDialog & check out next week. On research I have known that this exception stands if soething is not closed properly. Do you see any other possibility in the attached code or eVC has any internal problem accessing an more than 1 external object which does all database related activitlies. But the methods used here just does retriving objects from map which has all records read from the file.

    Thanks Terry

    C / C++ / MFC help question c++ debugging

  • 0xC000001D "Fatal Application Error" ????
    T Trupti Mehta

    BOOL CPPage1::OnApply()
    {
    // TODO: Add your specialized code here and/or call the base class
    AfxMessageBox(_T("CPPage1:: OnApply\n"));

    g\_pView->SendMessage(WM\_USERAPPLY);
    return TRUE;  //CPropertyPage::OnApply();
    

    }

    LRESULT CMC_AppView::OnUserApply(WPARAM wParam, LPARAM lParam)
    {
    TRACE(_T("VIEW::OnUserApply - wParam %x\n"), wParam);
    CString t("Operator No = ");
    AfxMessageBox(t); // m_sheet.m_page1.m_opNo);
    // m_sheet.SetAttributes();
    m_sheet.EndDialog(IDOK);
    return 0;
    }

    OnApply calls the OnUserApply. I get the "Operator No = " AfxMessage & then the fatal error comes. Thanks Terry

    C / C++ / MFC help question c++ debugging

  • 0xC000001D "Fatal Application Error" ????
    T Trupti Mehta

    Rajesh, I use eVC++ & run the application via ActieSync. But I believe that I cannot debug in this scenario. Like On Abort/Retry/Ignore, press Retry & the debugger will come on the error line. No that's not possible. What all AfxMessageBox, you see all are for debugging purpose only mainly.

    Thanks Terry

    C / C++ / MFC help question c++ debugging
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups