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
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. c++ GetUpperBound equivalent

c++ GetUpperBound equivalent

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++help
10 Posts 2 Posters 30 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ccodebase
    wrote on last edited by
    #1

    i have the Following vb.net 2008 routine i am trying to get c++ to have the same functionality having alot of issues with c++ conversion, any help with this would be great...

    Public Sub New()
    Try
    If ORIHoles Is Nothing Then
    ReDim ORIHoles(49)
    Dim ff As Integer = FreeFile()
    Dim tempstr As String
    Dim atempstr() As String
    FileOpen(ff, "postable.csv", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
    Do While Not EOF(ff)
    tempstr = LineInput(ff)
    atempstr = tempstr.Split(",")
    If atempstr.GetUpperBound(0) = 2 Then
    ORIHoles(CInt(atempstr(0))).Angle = CDbl(atempstr(1))
    ORIHoles(CInt(atempstr(0))).Hypot = CDbl(atempstr(2))
    End If
    Loop
    FileClose(ff)
    End If
    Catch ex As Exception
    GeneralErrorHandler(ex.ToString)
    End Try
    End Sub

    L 2 Replies Last reply
    0
    • C ccodebase

      i have the Following vb.net 2008 routine i am trying to get c++ to have the same functionality having alot of issues with c++ conversion, any help with this would be great...

      Public Sub New()
      Try
      If ORIHoles Is Nothing Then
      ReDim ORIHoles(49)
      Dim ff As Integer = FreeFile()
      Dim tempstr As String
      Dim atempstr() As String
      FileOpen(ff, "postable.csv", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
      Do While Not EOF(ff)
      tempstr = LineInput(ff)
      atempstr = tempstr.Split(",")
      If atempstr.GetUpperBound(0) = 2 Then
      ORIHoles(CInt(atempstr(0))).Angle = CDbl(atempstr(1))
      ORIHoles(CInt(atempstr(0))).Hypot = CDbl(atempstr(2))
      End If
      Loop
      FileClose(ff)
      End If
      Catch ex As Exception
      GeneralErrorHandler(ex.ToString)
      End Try
      End Sub

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Why are you posting VB.NET questions in the C++ forum, instead of Visual Basic Discussion Boards[^] ?

      1 Reply Last reply
      0
      • C ccodebase

        i have the Following vb.net 2008 routine i am trying to get c++ to have the same functionality having alot of issues with c++ conversion, any help with this would be great...

        Public Sub New()
        Try
        If ORIHoles Is Nothing Then
        ReDim ORIHoles(49)
        Dim ff As Integer = FreeFile()
        Dim tempstr As String
        Dim atempstr() As String
        FileOpen(ff, "postable.csv", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
        Do While Not EOF(ff)
        tempstr = LineInput(ff)
        atempstr = tempstr.Split(",")
        If atempstr.GetUpperBound(0) = 2 Then
        ORIHoles(CInt(atempstr(0))).Angle = CDbl(atempstr(1))
        ORIHoles(CInt(atempstr(0))).Hypot = CDbl(atempstr(2))
        End If
        Loop
        FileClose(ff)
        End If
        Catch ex As Exception
        GeneralErrorHandler(ex.ToString)
        End Try
        End Sub

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        ccodebase wrote:

        having alot of issues with c++ conversion

        Unless you tell us what thos issues are we cannot help you correct them. And please post your questions once only.

        C 1 Reply Last reply
        0
        • L Lost User

          ccodebase wrote:

          having alot of issues with c++ conversion

          Unless you tell us what thos issues are we cannot help you correct them. And please post your questions once only.

          C Offline
          C Offline
          ccodebase
          wrote on last edited by
          #4

          ok well, the issue is i need exact functionality in C++ with a class or function that performs as the vb.net code does, i do have this that i am hard coding all the Values into, CSV Structure is 01,-0.12343,1.34532 02,-0.62343,1.74532 03,-0.22343,1.34532 04,-0.62343,1.74532

          using namespace std;

          int main()

          {

          // initialize container 
          
          map mp; 
          
          
          
          // insert elements 
          
          mp.insert({ -0.12343, 1.34532}); /// used as example
          

          mp.insert({ 0.22343, 1.74532});

          mp.insert({ -0.12343, 1.34532});

          mp.insert({ -0.12343, 1.34532});

          // when 11 is present 
          
          auto it = mp.upper\_bound(11); 
          
          cout << "The upper bound of key 11 is "; 
          
          cout << (\*it).first << " " << (\*it).second << endl; 
          
          
          
          // when 13 is not present 
          
          it = mp.upper\_bound(13); 
          
          cout << "The upper bound of key 13 is "; 
          
          cout << (\*it).first << " " << (\*it).second << endl; 
          
          
          
          // when 17 is exceeds the maximum key, so size 
          
              // of mp is returned as key and value as 0. 
          
          it = mp.upper\_bound(17); 
          
          cout << "The upper bound of key 17 is "; 
          
          cout << (\*it).first << " " << (\*it).second; 
          
          return 0; 
          

          }

          ​

          9:23

          The upper bound of key 11 is 12 30
          The upper bound of key 13 is 14 40
          The upper bound of key 17 is 4 0

          L 2 Replies Last reply
          0
          • C ccodebase

            ok well, the issue is i need exact functionality in C++ with a class or function that performs as the vb.net code does, i do have this that i am hard coding all the Values into, CSV Structure is 01,-0.12343,1.34532 02,-0.62343,1.74532 03,-0.22343,1.34532 04,-0.62343,1.74532

            using namespace std;

            int main()

            {

            // initialize container 
            
            map mp; 
            
            
            
            // insert elements 
            
            mp.insert({ -0.12343, 1.34532}); /// used as example
            

            mp.insert({ 0.22343, 1.74532});

            mp.insert({ -0.12343, 1.34532});

            mp.insert({ -0.12343, 1.34532});

            // when 11 is present 
            
            auto it = mp.upper\_bound(11); 
            
            cout << "The upper bound of key 11 is "; 
            
            cout << (\*it).first << " " << (\*it).second << endl; 
            
            
            
            // when 13 is not present 
            
            it = mp.upper\_bound(13); 
            
            cout << "The upper bound of key 13 is "; 
            
            cout << (\*it).first << " " << (\*it).second << endl; 
            
            
            
            // when 17 is exceeds the maximum key, so size 
            
                // of mp is returned as key and value as 0. 
            
            it = mp.upper\_bound(17); 
            
            cout << "The upper bound of key 17 is "; 
            
            cout << (\*it).first << " " << (\*it).second; 
            
            return 0; 
            

            }

            ​

            9:23

            The upper bound of key 11 is 12 30
            The upper bound of key 13 is 14 40
            The upper bound of key 17 is 4 0

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Sorry I don't understand. You declare a map and then try to store double values into it. And what are 11, 13 and 17 supposed to relate to?

            C 1 Reply Last reply
            0
            • C ccodebase

              ok well, the issue is i need exact functionality in C++ with a class or function that performs as the vb.net code does, i do have this that i am hard coding all the Values into, CSV Structure is 01,-0.12343,1.34532 02,-0.62343,1.74532 03,-0.22343,1.34532 04,-0.62343,1.74532

              using namespace std;

              int main()

              {

              // initialize container 
              
              map mp; 
              
              
              
              // insert elements 
              
              mp.insert({ -0.12343, 1.34532}); /// used as example
              

              mp.insert({ 0.22343, 1.74532});

              mp.insert({ -0.12343, 1.34532});

              mp.insert({ -0.12343, 1.34532});

              // when 11 is present 
              
              auto it = mp.upper\_bound(11); 
              
              cout << "The upper bound of key 11 is "; 
              
              cout << (\*it).first << " " << (\*it).second << endl; 
              
              
              
              // when 13 is not present 
              
              it = mp.upper\_bound(13); 
              
              cout << "The upper bound of key 13 is "; 
              
              cout << (\*it).first << " " << (\*it).second << endl; 
              
              
              
              // when 17 is exceeds the maximum key, so size 
              
                  // of mp is returned as key and value as 0. 
              
              it = mp.upper\_bound(17); 
              
              cout << "The upper bound of key 17 is "; 
              
              cout << (\*it).first << " " << (\*it).second; 
              
              return 0; 
              

              }

              ​

              9:23

              The upper bound of key 11 is 12 30
              The upper bound of key 13 is 14 40
              The upper bound of key 17 is 4 0

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Try this:

              map mp;
              mp.insert({5,7}); /// used as example
              mp.insert({7,33});
              mp.insert({11,1});
              mp.insert({16,5});
              auto it = mp.upper_bound(11);
              cout << "The upper bound of key 11 is ";
              cout << it->first << " " << it->second << endl;

              C 2 Replies Last reply
              0
              • L Lost User

                Try this:

                map mp;
                mp.insert({5,7}); /// used as example
                mp.insert({7,33});
                mp.insert({11,1});
                mp.insert({16,5});
                auto it = mp.upper_bound(11);
                cout << "The upper bound of key 11 is ";
                cout << it->first << " " << it->second << endl;

                C Offline
                C Offline
                ccodebase
                wrote on last edited by
                #7

                this is a vision cart reader as the carts are read it has a certain pattern in the grid so what the initial goal was to provide an equivalent Class or function to the vb.net snippet earlier in the post it reads a CSV file that has 48 Values pertaining to locations on a 7 x 7 Grid 7^2

                Org CSV Structure is

                01,-0.12343,1.34532
                02,-0.62343,1.74532
                03,-0.22343,1.34532
                04,-0.62343,1.74532
                ..
                through 48

                when the camera system see's the holes through the Cart by light it knows what number it is

                1 Reply Last reply
                0
                • L Lost User

                  Sorry I don't understand. You declare a map and then try to store double values into it. And what are 11, 13 and 17 supposed to relate to?

                  C Offline
                  C Offline
                  ccodebase
                  wrote on last edited by
                  #8

                  so would it be

                  map

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    Try this:

                    map mp;
                    mp.insert({5,7}); /// used as example
                    mp.insert({7,33});
                    mp.insert({11,1});
                    mp.insert({16,5});
                    auto it = mp.upper_bound(11);
                    cout << "The upper bound of key 11 is ";
                    cout << it->first << " " << it->second << endl;

                    C Offline
                    C Offline
                    ccodebase
                    wrote on last edited by
                    #9

                    Reader: Base 7 o = HOLE 0 1 2 3 4 5 6 * * * * * o * o * * * * * * * o * * * * * * * * * * * 0 * * * * o * * * * * o * * * * * o * * * * 5 x 1 = 0 x 7 = 1 x 49 = 6 x 343 = 4 x 2401 = 3 x 16807 = 2 x 117649 = ---------------------------- SUM : (CART-ID)

                    1 Reply Last reply
                    0
                    • C ccodebase

                      so would it be

                      map

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      If you want to save double values then obviously yes.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

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