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. Visual Basic
  4. New to VB. Help needed.

New to VB. Help needed.

Scheduled Pinned Locked Moved Visual Basic
helptutoriallearning
13 Posts 5 Posters 0 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.
  • N nlarson11

    Dim myCalc As New Calculator.DateCalc2008() //THE PROBLEM!

    take off the work Calculator

    Dim myCalc As New DateCalc2008()

    DateCalc2008 would need to be nested within Calculator to be declared like that.

    'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

    G Offline
    G Offline
    gjx_junxian1989
    wrote on last edited by
    #4

    I tried, but still has the error. ok. cause i following the directions of a book, it taught me this way. "To run your new DLL file, you need to add a project with a user interface to the same solution that holds your DLL project." so, the Class DateCalc2008 is the .dll file which is used as a reference for the user interface which is the class Calculator. Thanks Alot! =)

    C 1 Reply Last reply
    0
    • G gjx_junxian1989

      I tried, but still has the error. ok. cause i following the directions of a book, it taught me this way. "To run your new DLL file, you need to add a project with a user interface to the same solution that holds your DLL project." so, the Class DateCalc2008 is the .dll file which is used as a reference for the user interface which is the class Calculator. Thanks Alot! =)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #5

      Does your new project have a reference to your dll ? If not, that would cause this error.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      G 1 Reply Last reply
      0
      • C Christian Graus

        Does your new project have a reference to your dll ? If not, that would cause this error.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        G Offline
        G Offline
        gjx_junxian1989
        wrote on last edited by
        #6

        yup. it does. Assuming i am following the book correctly, which im pretty sure i am. what does each part of this code means anyway? "Dim myCalc As New DateCalc2008()". just a thought, so usually if i were to have a class and want to create instances of it, i could just write it all out on the long sheet of codes instead of using the .dll as reference method? Thanks a million!

        C 1 Reply Last reply
        0
        • G gjx_junxian1989

          yup. it does. Assuming i am following the book correctly, which im pretty sure i am. what does each part of this code means anyway? "Dim myCalc As New DateCalc2008()". just a thought, so usually if i were to have a class and want to create instances of it, i could just write it all out on the long sheet of codes instead of using the .dll as reference method? Thanks a million!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #7

          gjx_junxian1989 wrote:

          Dim myCalc As New DateCalc2008()

          It means, create a new object, call it myCalc, and initialise it by calling the constructor of DateCalc2008.

          gjx_junxian1989 wrote:

          ust a thought, so usually if i were to have a class and want to create instances of it, i could just write it all out on the long sheet of codes instead of using the .dll as reference method?

          The only reason for the dll reference, is that you put the code in a dll. You would rarely do this, and I'm shocked that a book is telling you to mess with dlls, before explaining to you what a constructor does. If you have a reference to the dll, then you DO need to reference the full namespace of the dll, to get access to the object. If you start to type in the name of the top level namespace in the dll, autocomplete should kick in. If it doesn't, I doubt you have that reference. Also, if you made the reference, THEN added the class, you probably need to remove and re-add the reference to update it.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          G 1 Reply Last reply
          0
          • C Christian Graus

            gjx_junxian1989 wrote:

            Dim myCalc As New DateCalc2008()

            It means, create a new object, call it myCalc, and initialise it by calling the constructor of DateCalc2008.

            gjx_junxian1989 wrote:

            ust a thought, so usually if i were to have a class and want to create instances of it, i could just write it all out on the long sheet of codes instead of using the .dll as reference method?

            The only reason for the dll reference, is that you put the code in a dll. You would rarely do this, and I'm shocked that a book is telling you to mess with dlls, before explaining to you what a constructor does. If you have a reference to the dll, then you DO need to reference the full namespace of the dll, to get access to the object. If you start to type in the name of the top level namespace in the dll, autocomplete should kick in. If it doesn't, I doubt you have that reference. Also, if you made the reference, THEN added the class, you probably need to remove and re-add the reference to update it.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            G Offline
            G Offline
            gjx_junxian1989
            wrote on last edited by
            #8

            ic. Thanks alot. so if im not wrong, Dim myCalc As New DateCalc2008(), creates an object myCalc, which thus enables me to gain access to functions and variables in the class DateCalc2008 and assigning values to it. so the DateCalc2008 is like a template for many other uses of same application? But usually we write classes and make objects of the class in a single sheet of code?

            C 1 Reply Last reply
            0
            • G gjx_junxian1989

              ic. Thanks alot. so if im not wrong, Dim myCalc As New DateCalc2008(), creates an object myCalc, which thus enables me to gain access to functions and variables in the class DateCalc2008 and assigning values to it. so the DateCalc2008 is like a template for many other uses of same application? But usually we write classes and make objects of the class in a single sheet of code?

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #9

              gjx_junxian1989 wrote:

              so the DateCalc2008 is like a template for many other uses of same application? But usually we write classes and make objects of the class in a single sheet of code?

              Not really. A class would be created in one file inside your project, other classes, in other files, would create instances of the class and use them

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              G 1 Reply Last reply
              0
              • C Christian Graus

                gjx_junxian1989 wrote:

                so the DateCalc2008 is like a template for many other uses of same application? But usually we write classes and make objects of the class in a single sheet of code?

                Not really. A class would be created in one file inside your project, other classes, in other files, would create instances of the class and use them

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                G Offline
                G Offline
                gjx_junxian1989
                wrote on last edited by
                #10

                ok. Hey, thanks, you've been a great help. Is there anyway i can contact u in future if i have problems with VB? :-D

                C 1 Reply Last reply
                0
                • G gjx_junxian1989

                  ok. Hey, thanks, you've been a great help. Is there anyway i can contact u in future if i have problems with VB? :-D

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #11

                  I don't actually do VB, I just help here b/c it's all .NET. There's other people on these forums far better at VB than me, your best bet is to ask here, I'm here all the time, so I'll answer if no-one else does

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  G 1 Reply Last reply
                  0
                  • C Christian Graus

                    I don't actually do VB, I just help here b/c it's all .NET. There's other people on these forums far better at VB than me, your best bet is to ask here, I'm here all the time, so I'll answer if no-one else does

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    G Offline
                    G Offline
                    gjx_junxian1989
                    wrote on last edited by
                    #12

                    Alright! Thanks man! :-D

                    1 Reply Last reply
                    0
                    • G gjx_junxian1989

                      Hi. Im new to visual basic 2008. I am now learning classes and how to make an instance of a class. Below are my codes. I have a problem in which the system says my "Calculator.DateCalc2008()" is not defined. The following is my class code. PublicClass DateCalc2008 Private _startDate As DateTime Private _endDate As DateTime Private _span AsInteger PublicProperty StartDate() As DateTime Get StartDate = _startDate EndGet Set(ByVal value As DateTime) _startDate = value EndSet EndProperty PublicProperty EndDate() As DateTime Get EndDate = _endDate EndGet Set(ByVal value As DateTime) _endDate = value EndSet EndProperty PublicProperty Span() AsInteger Get Span = _span EndGet Set(ByVal value AsInteger) _span = value EndSet EndProperty PublicSub IncreaseDate() EndDate = StartDate.AddDays(Span) EndSub EndClass This is my object codes. Reference from above. PublicClass Calculator PrivateSub StartDatePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartDatePicker.ValueChanged Dim myCalc AsNew Calculator.DateCalc2008() //THE PROBLEM! myCalc.StartDate = StartDatePicker.Value myCalc.Span = 7 myCalc.IncreaseDate() EndDate.Text = myCalc.EndDate.ToString() EndSub EndClass

                      C Offline
                      C Offline
                      chilinhhacker
                      wrote on last edited by
                      #13

                      I'm not good at English. Not enough data to answer, because you didn't say about all the parts in your project and your project name. May be you have a class named "DateCalc2008" and a form named "Calculator". The form "Calculator" has a control named "StartDatePicker", and you created a subroutine which handles "StartDatePicker.ValueChanged" event. The error is: The form "Calculator" doesn't have a member named DateCalc2008. You should fix your code like this:

                      Dim myCalc As New {project name}.DateCalc2008

                      I hope this will be an useful answer. Good luck !

                      chilinhhacker

                      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