Computer Hope
Software => Computer programming => Topic started by: macdad- 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.
-
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
-
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.
-
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.
-
Ok, add a refrence to your dll.
Then your code should be something like this (If you are using VB.net)
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.
-
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]
-
That didn't work... please put the dll in a zip folder and put that on here.
Thanks,
Bones
-
ok here...
[file cleanup - saving space - attachment deleted by admin]
-
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?
-
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.
-
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)
-
the Download(By Ref String is the function that sends the text to the RCX.
-
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
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
-
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"
-
What did you use for your usb port number?
-
1. but how do i find out what usb port # its on?
-
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?
-
ok i change the number to many times and still i get the same error message.
-
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?
-
the help file that came with the dll is to large can i send it to u by email?
-
Feel free. I will PM you my email.
-
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.
-
its ok thank you for trying.