Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: For a newbie, C++ or Java or what?  (Read 13050 times)

0 Members and 1 Guest are viewing this topic.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: For a newbie, C++ or Java or what?
« Reply #15 on: February 28, 2009, 11:07:49 AM »
what doesn't bloat up the system as much as VB6? it sure as heck isn't .NET...


usercontrols? ActiveX designers? Creating these is the only way to truly know pain.

Well that and modifying class instance Vtables...
I was trying to dereference Null Pointers before it was cool.

macdad-



    Expert

    Thanked: 40
    Re: For a newbie, C++ or Java or what?
    « Reply #16 on: February 28, 2009, 11:09:12 AM »
    VB6 doesnt bloat up my rig like .NET does.

    but still, VB6 is great
    If you dont know DOS, you dont know Windows...

    Thats why Bill Gates created the Windows NT Family.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: For a newbie, C++ or Java or what?
    « Reply #17 on: February 28, 2009, 11:11:23 AM »
    wanna see more impossibly complex code?  ;D
    I was trying to dereference Null Pointers before it was cool.

    macdad-



      Expert

      Thanked: 40
      Re: For a newbie, C++ or Java or what?
      « Reply #18 on: February 28, 2009, 11:12:46 AM »
      no now.
      If you dont know DOS, you dont know Windows...

      Thats why Bill Gates created the Windows NT Family.

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: For a newbie, C++ or Java or what?
      « Reply #19 on: February 28, 2009, 11:44:40 AM »
      no now.

      Alright, I'll show you some simple code then.

      Code: [Select]
      Public Function GetDriveForNtDeviceName( _
         ByVal sDeviceName As String) As String
      Dim sFoundDrive As String
      Dim strdrives As String
      Dim DriveStr() As String
      Dim vDrive As String, i As Long, ret As Long
      strdrives = Space$(256)
      ret = GetLogicalDriveStrings(255, strdrives)
      strdrives = Trim$(Replace$(strdrives, vbNullChar, " "))
      DriveStr = Split(strdrives, " ")
         'For Each vDrive In GetDrives()
         For i = 0 To UBound(DriveStr)
          vDrive = DriveStr(i)
            If StrComp(GetNtDeviceNameForDrive(vDrive), sDeviceName, vbTextCompare) = 0 Then
               sFoundDrive = vDrive
               Exit For
            End If
         Next i
         
         GetDriveForNtDeviceName = sFoundDrive
         
      End Function


      Wait. whoops. I guess it's a matter of opinion...
      I was trying to dereference Null Pointers before it was cool.

      macdad-



        Expert

        Thanked: 40
        Re: For a newbie, C++ or Java or what?
        « Reply #20 on: February 28, 2009, 11:55:59 AM »
        i think i get the Code, does it step through each existing Drive on a sys and list the Existing Drives?
        If you dont know DOS, you dont know Windows...

        Thats why Bill Gates created the Windows NT Family.

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: For a newbie, C++ or Java or what?
        « Reply #21 on: February 28, 2009, 12:58:12 PM »
        actually, what it does is right in the name of the function  :P

        GetDriveForNtDeviceName

        for example passing in "\Device\HarddiskVolume1" on my PC returns "C:\"

        same for "\Device\Floppy0" returning "A:\"
        I was trying to dereference Null Pointers before it was cool.

        macdad-



          Expert

          Thanked: 40
          Re: For a newbie, C++ or Java or what?
          « Reply #22 on: February 28, 2009, 04:04:39 PM »
          atleast i knew that it was related to someone's drives
          If you dont know DOS, you dont know Windows...

          Thats why Bill Gates created the Windows NT Family.

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: For a newbie, C++ or Java or what?
          « Reply #23 on: February 28, 2009, 08:59:26 PM »
          Only because of "GetLogicalDriveStrings"

          I could have aliased the function to be, like, "lpGetFluffyKittyCount" or something.

          THAT would make for some very confusing File library code...
          I was trying to dereference Null Pointers before it was cool.

          macdad-



            Expert

            Thanked: 40
            Re: For a newbie, C++ or Java or what?
            « Reply #24 on: March 01, 2009, 03:44:28 PM »
            Hmm....lets see..here's my Slot Machine Game written entirely in VB6:

            Code: [Select]
            Dim s1 As Integer
            Dim s2 As Integer
            Dim s3 As Integer

            Private Declare Function BeepAPI Lib "kernel32" Alias "Beep" (ByVal dwFrequency _
                As Long, ByVal dwMilliseconds As Long) As Long

            Private Sub btnPull_Click()
            If bag.Text = "0" Then
             MsgBox ("Your Broke! Game Over"), , "Game Over"
             End
            Else
            If Coins.Text = "" Then
            MsgBox ("Insert a coin to play"), , "No Coin"
            Else
            bag = bag - 1
            Randomize
            s1 = Int(Rnd * 4)
            s2 = Int(Rnd * 4)
            s3 = Int(Rnd * 4)
            BeepAPI 600, 100
            'picture 1



            If s1 = 0 Or s1 = 3 Then
            Pic1.Picture = LoadPicture(App.Path & "\b.bmp")
            End If
            If s1 = 1 Then
            Pic1.Picture = LoadPicture(App.Path & "\c.bmp")
            End If
            If s1 = 2 Then
            Pic1.Picture = LoadPicture(App.Path & "\s.bmp")
            End If
            'picture 2
            If s2 = 0 Or s2 = 3 Then
            Pic2.Picture = LoadPicture(App.Path & "\b.bmp")
            End If
            If s2 = 1 Then
            Pic2.Picture = LoadPicture(App.Path & "\c.bmp")
            End If
            If s2 = 2 Then
            Pic2.Picture = LoadPicture(App.Path & "\s.bmp")
            End If
            'picture 3
            If s3 = 0 Or s3 = 3 Then
            Pic3.Picture = LoadPicture(App.Path & "\b.bmp")
            End If
            If s3 = 1 Then
            Pic3.Picture = LoadPicture(App.Path & "\c.bmp")
            End If
            If s3 = 2 Then
            Pic3.Picture = LoadPicture(App.Path & "\s.bmp")
            End If
            If s1 = 1 And s2 = 1 And s3 = 1 Then
             BeepAPI 800, 100
             BeepAPI 900, 100
             MsgBox ("You Win 5 Coins!"), , "Win"
            bag = 5 + bag
            End If
            If s1 = 2 And s2 = 2 And s3 = 2 Then
             BeepAPI 800, 100
             BeepAPI 900, 100
             MsgBox ("Jack-Pot! 20 Coins!"), , "Win"
             bag = 20 + bag
            End If
            End If
            End If
            End Sub

            Private Sub Form_Load()
            bag.Text = bag
            bag = 50
            End Sub



            [attachment deleted by admin]
            If you dont know DOS, you dont know Windows...

            Thats why Bill Gates created the Windows NT Family.

            Geek-9pm

              Topic Starter

              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: For a newbie, C++ or Java or what?
            « Reply #25 on: March 01, 2009, 05:20:43 PM »
            Wat about Java?
            If a newbie was to learn Java, what materials should he use?
            (Not JavaScript, please!)
            What IDE?
            What text book?
            What Web Sites?
            Why don't the teach Java in high school courses?
            And I don't want to see any more:
            Code: [Select]
            Dim s1 As Integer
            Dim s2 As Integer
            Dim s3 As Integer
            That is so pointless.

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: For a newbie, C++ or Java or what?
            « Reply #26 on: March 01, 2009, 08:50:59 PM »
            And I don't want to see any more:
            Code: [Select]
            Dim s1 As Integer
            Dim s2 As Integer
            Dim s3 As Integer
            That is so pointless.


            yes... easier to do:
            Code: [Select]
            Dim s1%,s2%,s3%

            Actually, really it isn't as much typing, since you can type "Dim s1 as I" and then space, due to autocomplete. Although a much better way would be

            Code: [Select]
            Dim s(1 to 3) as Integer




            Anyways... for a Java IDE there is a free version available from sun, "NetBeans" I believe. If I recall it had some steep performance issues, though. I don't know of any Java textbooks myself- just get them to stay away from those insulting "learn Java in 24 hours!" type books  ::).
            I was trying to dereference Null Pointers before it was cool.

            Geek-9pm

              Topic Starter

              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: For a newbie, C++ or Java or what?
            « Reply #27 on: March 01, 2009, 09:01:33 PM »
            Quote
            learn Java in 24 hours!"

            ...was that anything like "Learn Red Hat Linux in 21 Days" ?
            Got rid of that book after two years.

            ===========================
            VB6 is able to do variant types, -Right?
            So it should know if you need Integer or not.
            (Or am I thinking VB script.)
            Just don't dim anything!. It should work anyway!
            And if it goes slower, it is more fun!


            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: For a newbie, C++ or Java or what?
            « Reply #28 on: March 01, 2009, 09:19:04 PM »
            Quote
            learn Java in 24 hours!"

            ...was that anything like "Learn Red Hat Linux in 21 Days" ?
            Got rid of that book after two years.


            See what I mean? That's the quality of all of them, pretty much.


            VB6 is able to do variant types, -Right?
            So it should know if you need Integer or not.
            (Or am I thinking VB script.)
            Just don't dim anything!. It should work anyway!
            And if it goes slower, it is more fun!
            [/color]


            In the default configuration VB6 will allow you to not need to declare any variables. However- Standard practice is to include "Option Explicit" at the top of all Form,Class, and Code modules. This is to avoid tricky typo errors being almost impossible to catch:

            Code: [Select]

            Private Function Multiply(ByVal Multiplicand1,ByVal Multiplicand2,Byval Multiplicand3)

            Multiply = Multiplicand1 * Multiplicand2 * Multiplicend3

            end Function


            notice the typo? Well, if Option Explicit is on, so will VB... otherwise it will become a puzzle why every single return from the function is 0, regardless of the input.

            That was a simple example though- in far more complicated procedures it becomes torture trying to find ann the implicitly declared variables. This is why it's easier, in the long run, the declare all variables.

            I only use Variant for Procedure parameters that can accept multiple types, Or when I need to use the "Decimal" type, which is only valid via Variant variables.

            Also it will go MUCH slower being dimmed as Variant/Implicitly as you've stated; although that isn't the real issue, one could easily change the default variable type via a DefInt,DefLng,DefSng,DefDbl,DefStr metacommand at the top of a module... but it simply makes it easier to debug.
            I was trying to dereference Null Pointers before it was cool.

            macdad-



              Expert

              Thanked: 40
              Re: For a newbie, C++ or Java or what?
              « Reply #29 on: March 02, 2009, 06:57:45 AM »
              i wrote it like a year ago, and i didn't realize you could do that(besides the array method)

              but still its pretty good, eh?
              If you dont know DOS, you dont know Windows...

              Thats why Bill Gates created the Windows NT Family.