|
VB6 is outdated and useless. It sounds like you're doing beginner projects. Drop that smelly dog of a language and learn something that will lead to actual employment, as well as giving you the tools you need to write the applications that you're going to want to be able to write.
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.
|
|
|
|
|
On top of what Christian said (yes, VB6 is old, outdated, and unsupported) this would require you to implement a global keyboard hook, something that VB6 alone is incapable of doing.
|
|
|
|
|
I have a text file in c:\ as abc.txt
which displays
empid=e001, name=john, salary=5000
..
...
.....
Now, we need to have a method which wil take empid as parameter and will find the line with the empid and create a text file with that line
e.g if we pass e001 to the method
it will write
empid=e001, name=john, salary=5000
to a new file with the name e001
So all these files created will be stored in a folder c:\repository
Could you please help to code that in vb.net.
Many thanks
|
|
|
|
|
Sound trivial, a little bit of regex, some basic file management code. In fact, string.Split would do it fine. Perhaps if you don't know how to do it, you should advertise for someone to write it for you. Be careful tho, a lot of the people who place low bids on projects nowadays, barely know how to type. They come here and post their projects and hope someone will do it for 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.
|
|
|
|
|
My reply actually contained all the info someone would need to write this code, but I get a 1 vote for not doing the work for you ? I'm happy to provide my contract rates.
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.
|
|
|
|
|
Evened it out for you
I guess the guy can't read since you did give him the answer to his question all be it in a somewhat obscure form
|
|
|
|
|
I try to always give answers that a programmer, or someone who has read my article on how to use google, should be able to use to solve their problem. I don't really provide code often anymore.
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.
|
|
|
|
|
This is simply knowing how to manipulate strings and files. If you don't know these simple techniques, you really have no business even starting this project. Seriously, if you want to continue to write code, pickup on beginners book on VB.NET and work through it. Without these basic concepts, you have no hope of completing the simplest of projects, like this one.
|
|
|
|
|
i have a third party .dll file which was provided with a hardware, i also have a .lib and .h file. i have included the dll file into my working folder and added the following code into my VB app, but still it gives an error "Runtime error 53 - file not found", i tried all the things that are suggested in various forums but still the problem exists
Option Explicit
Private Declare Function Connect Lib "E:\Projects\Sample Code\vb Test\device.dll" (ByRef h As Long, ByVal ID As Byte, ByVal nullptr As Long, ByVal speed As Long, ByVal proto As Byte) As Long
on command click i have written the following code
Private Sub btnConnect_Click()
Dim dvReturn As Long
Dim dvHandle As Long
Dim port As Byte
Dim speed As Long
Dim protocol As Byte
port = 1
speed = 9600
protocol = 4
dvReturn = Connect(dvHandle, port, 0, speed, protocol)
If dvReturn Then
lblStatus.Caption = "Failed"
Else
lblStatus.Caption = "Connected"
End If
End Sub
the function prototype in the .h file is as follows
extern unsigned long __cdecl Connect(unsigned long *h,unsigned char ID,void *,unsigned long, unsigned char);
can any one suggest what may be the problem
Naveen
|
|
|
|
|
Why are you not using unsigned longs in your declaration ?
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.
|
|
|
|
|
Hi,
several comments:
1.
as Christian said, keeping signed/unsigned correct would be better
2.
in most C/C++ environments a long takes 32-bit, in .NET that would be an Integer, not a Long.
3.
the void* should be something passed ByRef, not ByVal.
However, if the above were the only errors, I would expect a different message (such as "method not found").
4.
why are you using the full file path? this makes porting your app to a different PC almost impossible. It should be sufficient to put the DLL file next to your EXE file (in bin/Debug or bin/Release).
5.
IF your DLL references other DLL files, and one of them isn't found, the same error message would appear.
they too should be either in your EXE's folder, or in some folder that is listed in the Windows PATH environment variable.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Here is an example:-
"string of 23 characters"
The above string has 23 characters, including the spaces
What I want to do is count the number of charactersand then split the string at the next space after the half number, in this case, half of 23 is rounded up to 12 so I need to split the string between the "3" and the "c" to read like this:-
"string of 23" and "characters"
I've tried various string functions, and combinations of them but cannot work out how to do it.
I'd appreciate your help.
Regards,
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
Hi,
I'm not going to give you any solution; I do suggest you try and solve this little task in several steps, it is a typical beginner's mistake to try and solve it in one complex statement (which often never gets composed correctly). With many statements, you can execute the required steps, similar to your explanation in English words, AND you can check intermediate results.
So don't worry if you use ten lines of code for this; once you got it working correctly, you can try and optimize it.
One hint: you don't need loops, a few simple string methods will do.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
You will could use the following methods of your string variable, to achieve your requirements :-
.Length
.Substring
.Replace
like so:-
Dim FullString = "string of 23 characters"
Dim FirstPart As String
Dim SecondPart As String
FirstPart = FullString
SecondPart = FullString.Substring(FullString.Length /2)
FirstPart = Replace(FirstPart, SecondPart, "")
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I think is this the code you need:
Dim FullString As String = "String of 23 characters"
Dim HalfStringLen As Integer = Fix(FullString.Length / 2)
Dim FirstPart As String = FullString
Dim SecondPart As String = ""
Do
If FullString(HalfStringLen) = " " Then
FirstPart = Microsoft.VisualBasic.Left(FullString, HalfStringLen)
SecondPart = LTrim(Microsoft.VisualBasic.Right(FullString, FullString.Length - HalfStringLen))
Exit Do
End If
HalfStringLen = HalfStringLen + 1
Loop Until HalfStringLen = FullString.Length At end of loop, FirstPart and SecondPart will contain FullString spitted.
Note that If the full string have not espaces, FirstPart will contain the entire FullString.
Ignazio
|
|
|
|
|
Hi Ignazio and Steve,
Thanks for your replies, they have both helped me a lot and it's helped me to solve my problem.
again, thanks
Steve
Thanks for your help and advice!
Steve
|
|
|
|
|
Congratulations! You managed to con someone into doing your work for you! Don't do it again.
|
|
|
|
|
I have a very strange request from client.
The scenario is: I have a server with some media file assigned to unique id's and the server is conected to a series of USB flash drives port (20). Now, a user comes down & plugin his/her USB drive. Every USB drive has an .txt file, the .txt file names are nothing but the unique id's which are already stored on server.
Once the user plugin he's/her USB drive, the server should be able to read the .txt file name(unique id) and get all the media files from the server and copy it to USB flash drive. Once its done we shouls close the port.
Just to let you guys know, no monitor will be there and once we copy the files to USB it should intimate the User.
I know it sounds strange. Any help / direction would be truly appreciated.
Thanks
Sagar
|
|
|
|
|
The hard part, I guess, is detecting the drive being attached. I'm not sure there's an event you can use, although autoplay does fire in the OS itself. You might just check what drives are connected every few seconds, and if you find a new one, go ahead and read the text file. It sounds straightforward from there, look up the files from the Ids and copy them. I'd expect a windows service to do this work.
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.
|
|
|
|
|
Hi,
nothing strange about that. Here are some pointers:
1.
inserting/removing a device generates a Windows message, which you can capture by overriding WndProc in your Form; here is a skeleton method for that (sorry it is C# code, VB.NET code can do similar things):
WM_DEVICECHANGE = 0x0219,
DBT_DEVICEARRIVAL= 0x8000,
DBT_DEVICEREMOVECOMPLETE= 0x8004,
protected override void WndProc(ref Message m) {
if (m.Msg==WM_DEVICECHANGE) {
int wParam=(int)m.WParam;
int lParam=(int)m.LParam;
log("WM_DEVICECHANGE wParam="+wParam.ToString("X8")+" lParam="+lParam.ToString("X8"));
if (wParam==DBT_DEVICEARRIVAL) DeviceAdded();
else if (wParam==DBT_DEVICEREMOVECOMPLETE) DeviceRemoved();
}
}
DeviceAdded() would be your method where most of the action is.
2.
rather than having text files to identify the users, I would use the unique ID that seems to be present in most if not all USB memory sticks; it can be obtained using WMI. Advantage is it is much more tamper proof, users could easily change their text file (unless you somehow encrypted it).
3.
warning: depending on USB stick manufacturer, Windows version, and/or system settings, the stick may or may not be cached; when it is, you need to use "Safely remove hardware" otherwise the next time the stick gets inserted in some system, a dialog "Should I scan and fix..." would appear.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
modified on Thursday, September 17, 2009 9:25 PM
|
|
|
|
|
Hey, Thank you for your response.
Felt good after reading "nothing strange" .
Reason for using a .txt file: the file name would be nothing but a unique Id. Bsacially I need to get that id and send it across to server, based on that id I need to pull few media assets which belogs id and need to copy it on USB drive.
Once we done with copying the files, we have to intimate the users.
Please note: no monitors will be there.
User could just see few USB ports to plugin the flash drive.
Any direction / helpo would be trul appreciated.
Thanks,
Sagar
|
|
|
|
|
Sagar Mishra wrote: Once we done with copying the files, we have to intimate the users.
Sagar Mishra wrote: no monitors will be there.
I see two ways:
1.
put a sticker "when your USB stick stops flashing, files got loaded; now wait 5 seconds and remove it."
(this is assuming your USB stick has a busy LED, I haven't seen any without LED yet).
2.
put a red LED on top of each USB receptacle; connect it to the PC, and switch it on when you detected the device presence, and off again when done copying plus 5 second wait.
This[^] may help if your system has a parallel port; a few LEDs can also be controlled through the control lines of a serial port.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Sagar Mishra wrote: Just to let you guys know, no monitor will be there and once we copy the files to USB it should intimate the User.
Marty's loud speakers works very well
Seriously probably a light/LED light connected to PCI slot should work, or through speaker.
Your next problem probably is how to tell the user an error has occurred, some files are not found on server, or the USB is full.
|
|
|
|
|
Yeah, do NOT email people to get a problem solved. I didn't answer because Luc's answers were already there and the best answer you're going to get.
In my humble opinion, basing things on the existance and filename of a text file on the stick is a bad idea. It's just too easy to accidentally delete/move/rename the text file.
|
|
|
|
|
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|