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

Author Topic: New to VB Express How do i work with Dll's  (Read 10736 times)

0 Members and 1 Guest are viewing this topic.

macdad-

    Topic Starter


    Expert

    Thanked: 40
    New to VB Express How do i work with Dll's
    « on: February 04, 2008, 08:14:30 PM »
    help!! im new to VB Express and im trying to make a prgm that sends files and words through a USB port.
    If you dont know DOS, you dont know Windows...

    Thats why Bill Gates created the Windows NT Family.

    Bones92



      Hopeful

    • Website Designer and Microcontroller Programmer
    • Thanked: 3
      • PIC Programming New Zealand
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: New to VB Express How do i work with Dll's
    « Reply #1 on: February 05, 2008, 01:43:33 AM »
    Well, you need to find the dll that lets you interface with the usb port (no, I don't know where it is), and then add a referance to it, and then import it into vb.net.

    These instructions may be improved if you tell me your:
    .Net framework
    Visual Studio being used
    Operating System

    Shynnie



      Intermediate

    • "All I want is his whereabouts, then I'm rich"..!!
      Re: New to VB Express How do i work with Dll's
      « Reply #2 on: February 05, 2008, 05:40:35 AM »
      If you try the upload file function which uploads the file to that port drive since if you connect a stiff on a usb port it will be assignned a drive letter.
      =============================================================

      "those who know how will always work 4 those who know why"

      “the absence of evidence is not the evidence of absence”

      macdad-

        Topic Starter


        Expert

        Thanked: 40
        Re: New to VB Express How do i work with Dll's
        « Reply #3 on: February 05, 2008, 02:19:24 PM »
        no i have the dll and i've seen the commands in the dll. but heres how my prgm is suppose to work.
        1st you type in a word or sentence in the textbox.
        2nd you press the send button and the dll should send the word or sentence to the device. the device is a Lego USB Tower that comes with the lego mindstorm set. the lego robot i made is a printer that can print letters, numbers, and graphics. so when i send whatever i type in the textbox the dll send the words to my lego robot which then prints out the words.
        If you dont know DOS, you dont know Windows...

        Thats why Bill Gates created the Windows NT Family.

        Bones92



          Hopeful

        • Website Designer and Microcontroller Programmer
        • Thanked: 3
          • PIC Programming New Zealand
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: New to VB Express How do i work with Dll's
        « Reply #4 on: February 05, 2008, 03:07:43 PM »
        Ok, add a refrence to your dll.

        Then your code should be something like this (If you are using VB.net)

        Code: [Select]
        Imports SomeDll 'replace this with your dll

        Public Class Form1

        Private WithEvents LegoThing as SomeDll 'only add withevents if your dll actually has events

        Private Sub SomeButton_Click(ByVal sender as object, ByVal e as System.EventArgs) _
                 Handles SomeButton.Click
                 
                 Try
                         LegoThing.PrintSomething(SomeTextBox.Text)
                 Catch ex as Exception
                         Msgbox("Error: " & ex.Message, msgboxstyle.critical, "An error has occured!")
                 End Try

        End Class


        I could help more if you tell me:
        The dll functions.
        Where to find/download this dll.

        macdad-

          Topic Starter


          Expert

          Thanked: 40
          Re: New to VB Express How do i work with Dll's
          « Reply #5 on: February 05, 2008, 03:37:29 PM »
          heres the dll its in txt format so you have to open it with notepad and save it as a DLL file. all the function are intact take ur time and reply back when u have the chance

          [file cleanup - saving space - attachment deleted by admin]
          If you dont know DOS, you dont know Windows...

          Thats why Bill Gates created the Windows NT Family.

          Bones92



            Hopeful

          • Website Designer and Microcontroller Programmer
          • Thanked: 3
            • PIC Programming New Zealand
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows 7
          Re: New to VB Express How do i work with Dll's
          « Reply #6 on: February 06, 2008, 12:09:02 AM »
          That didn't work... please put the dll in a zip folder and put that on here.
          Thanks,
          Bones

          macdad-

            Topic Starter


            Expert

            Thanked: 40
            Re: New to VB Express How do i work with Dll's
            « Reply #7 on: February 06, 2008, 06:06:12 AM »
            ok here...

            [file cleanup - saving space - attachment deleted by admin]
            If you dont know DOS, you dont know Windows...

            Thats why Bill Gates created the Windows NT Family.

            Bones92



              Hopeful

            • Website Designer and Microcontroller Programmer
            • Thanked: 3
              • PIC Programming New Zealand
            • Computer: Specs
            • Experience: Experienced
            • OS: Windows 7
            Re: New to VB Express How do i work with Dll's
            « Reply #8 on: February 06, 2008, 10:48:47 PM »
            Ok, I explored that dll and there is a heck of a lot of functions in it. Which ones am I using to send text and get a response?

            macdad-

              Topic Starter


              Expert

              Thanked: 40
              Re: New to VB Express How do i work with Dll's
              « Reply #9 on: February 07, 2008, 01:59:20 PM »
              ok there is first a command that says open port. the port i want to open is usb.
              then there is a command that says RCX2 which tells u the Brick type for IR compatibility
              after that there is a folder that says VPBrick open it and go to the command that says Download(By Ref String, which says send a letter or number to the RCX.
               
              If you dont know DOS, you dont know Windows...

              Thats why Bill Gates created the Windows NT Family.

              Bones92



                Hopeful

              • Website Designer and Microcontroller Programmer
              • Thanked: 3
                • PIC Programming New Zealand
              • Computer: Specs
              • Experience: Experienced
              • OS: Windows 7
              Re: New to VB Express How do i work with Dll's
              « Reply #10 on: February 07, 2008, 09:54:58 PM »
              Ok, I've found that. Which function do I use to send text out? (and realise there may be glitches, I have no lego mindstorms set to test it with)

              macdad-

                Topic Starter


                Expert

                Thanked: 40
                Re: New to VB Express How do i work with Dll's
                « Reply #11 on: February 08, 2008, 03:42:19 PM »
                the Download(By Ref String is the function that sends the text to the RCX.
                If you dont know DOS, you dont know Windows...

                Thats why Bill Gates created the Windows NT Family.

                Bones92



                  Hopeful

                • Website Designer and Microcontroller Programmer
                • Thanked: 3
                  • PIC Programming New Zealand
                • Computer: Specs
                • Experience: Experienced
                • OS: Windows 7
                Re: New to VB Express How do i work with Dll's
                « Reply #12 on: February 09, 2008, 05:58:24 PM »
                ok, this is what i've got from what you've told me, but it will need tweaking.

                Uses a button called Sendbtn and a textbox called SendTxtBox

                Code: [Select]
                Imports LEGOVPBrickLib

                Public Class Form1
                    Const MyPort As Integer = 1 'change this to your usb port

                    Private Sub SendBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendBtn.Click
                        Static LegoThing As LEGOVPBrickLib.VPBrick
                        Try
                            LegoThing.Open(MyPort.ToString)
                            LegoThing.Download(SendTxtBox.Text)
                        Catch ex As Exception
                            MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical, "An error has occured.")
                        End Try
                    End Sub
                End Class

                macdad-

                  Topic Starter


                  Expert

                  Thanked: 40
                  Re: New to VB Express How do i work with Dll's
                  « Reply #13 on: February 10, 2008, 03:43:50 PM »
                  ok the build succeded but when i press the SendBtn i get an error message that says "Error: Object reference not set to an instance of an object"
                  If you dont know DOS, you dont know Windows...

                  Thats why Bill Gates created the Windows NT Family.

                  Bones92



                    Hopeful

                  • Website Designer and Microcontroller Programmer
                  • Thanked: 3
                    • PIC Programming New Zealand
                  • Computer: Specs
                  • Experience: Experienced
                  • OS: Windows 7
                  Re: New to VB Express How do i work with Dll's
                  « Reply #14 on: February 11, 2008, 12:41:25 AM »
                  What did you use for your usb port number?

                  macdad-

                    Topic Starter


                    Expert

                    Thanked: 40
                    Re: New to VB Express How do i work with Dll's
                    « Reply #15 on: February 11, 2008, 02:17:38 PM »
                    1. but how do i find out what usb port # its on?
                    If you dont know DOS, you dont know Windows...

                    Thats why Bill Gates created the Windows NT Family.

                    Bones92



                      Hopeful

                    • Website Designer and Microcontroller Programmer
                    • Thanked: 3
                      • PIC Programming New Zealand
                    • Computer: Specs
                    • Experience: Experienced
                    • OS: Windows 7
                    Re: New to VB Express How do i work with Dll's
                    « Reply #16 on: February 11, 2008, 08:37:50 PM »
                    It won't be port 1, i'm not sure what that is, i was just using an example. I don't actually know, nor do I know how to find out... maybe someone else knows how to find out?

                    macdad-

                      Topic Starter


                      Expert

                      Thanked: 40
                      Re: New to VB Express How do i work with Dll's
                      « Reply #17 on: February 12, 2008, 05:25:26 PM »
                      ok i change the number to many times and still i get the same error message.
                      If you dont know DOS, you dont know Windows...

                      Thats why Bill Gates created the Windows NT Family.

                      Bones92



                        Hopeful

                      • Website Designer and Microcontroller Programmer
                      • Thanked: 3
                        • PIC Programming New Zealand
                      • Computer: Specs
                      • Experience: Experienced
                      • OS: Windows 7
                      Re: New to VB Express How do i work with Dll's
                      « Reply #18 on: February 12, 2008, 11:29:09 PM »
                      Code: [Select]
                      Imports LEGOVPBrickLib

                      Public Class Form1
                          Const MyPort As Integer = 1 'change this to your usb port

                          Private Sub SendBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendBtn.Click
                              Static LegoThing As New LEGOVPBrickLib.VPBrick '*new* was needed
                              Try
                                  LegoThing.Open(MyPort.ToString)
                                  LegoThing.Download(SendTxtBox.Text)
                              Catch ex As Exception
                                  MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical, "An error has occured.")
                              End Try
                          End Sub
                      End Class

                      I tried this on my computer but I believe your dll needs a heck of a lot of code to interface with it as it was returning a COMException and an InnerException, which means I need to dissassemble the dll to know what to send to it, which takes a very long time and is incredibly difficult. I could try, but
                      1: without the mindstorms set I have no way of testing it and
                      2: it would take me at least 2 weeks, probably 3 to write the code.

                      Is there a manual that comes with your mindstorms set which tells you how it can work? Or a ReadMe that came with the dll? Anything at all that came that can give me a headstart?

                      macdad-

                        Topic Starter


                        Expert

                        Thanked: 40
                        Re: New to VB Express How do i work with Dll's
                        « Reply #19 on: February 13, 2008, 06:03:04 AM »
                        the help file that came with the dll is to large can i send it to u by email?
                        If you dont know DOS, you dont know Windows...

                        Thats why Bill Gates created the Windows NT Family.

                        Bones92



                          Hopeful

                        • Website Designer and Microcontroller Programmer
                        • Thanked: 3
                          • PIC Programming New Zealand
                        • Computer: Specs
                        • Experience: Experienced
                        • OS: Windows 7
                        Re: New to VB Express How do i work with Dll's
                        « Reply #20 on: February 13, 2008, 09:11:57 PM »
                        Feel free. I will PM you my email.

                        Bones92



                          Hopeful

                        • Website Designer and Microcontroller Programmer
                        • Thanked: 3
                          • PIC Programming New Zealand
                        • Computer: Specs
                        • Experience: Experienced
                        • OS: Windows 7
                        Re: New to VB Express How do i work with Dll's
                        « Reply #21 on: February 17, 2008, 08:44:58 PM »
                        I'm very sorry, but It just won't work, no matter what I do. Do you know anybody who has successfully communicated with the set? You may have to ask them how its done.

                        I even tried and online "example" - it returned 57 errors.

                        Here is a link to a sample I found - its VB6, however

                        http://news.lugnet.com/robotics/?n=23464

                        Once again, I am very sorry.

                        macdad-

                          Topic Starter


                          Expert

                          Thanked: 40
                          Re: New to VB Express How do i work with Dll's
                          « Reply #22 on: February 18, 2008, 09:15:46 AM »
                          its ok thank you for trying.
                          If you dont know DOS, you dont know Windows...

                          Thats why Bill Gates created the Windows NT Family.