|
Try using the DragLeave event. It won't cancel the drag-drop, but it will allow you to remove the entry from the list once the mouse leaves the control.
|
|
|
|
|
I want to build a module to combine multiple text file in a .csv file by using vb.net.
My text file data like this:
(T1.txt)
UnitCode|Qty
001|56
002|45
003|100
004|78
005|67
(T2.txt)
UnitCode|Qty
001|78
002|166
003|10
005|12
I want the output like this:
(Output.csv)
UnitCode,T1,T2
001,56,78
002,45,166
003,100,10
004,78,
005,67,12
Anyone expert can help me?
|
|
|
|
|
You need to think this through logically. Use a StreamReader to open both files, use String.Split on each line of each text file and add it to a StringBuilder on each iteration, using a comma to separate each item. When you have finished traversing the text files, you can save the csv file using a StreamWriter.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
|
Just a simple sample
Sub Main()
Dim dict = New Dictionary(Of String, List(Of Integer))
Dim unitCode = String.Empty
Dim qty = 0
For Each file In GetFiles()
For Each row In file
unitCode = GetUnitCode(row)
qty = GetQuantity(row)
If dict.ContainsKey(unitCode) Then
dict(unitCode).Add(qty)
Else
Dim qtyList = New List(Of Integer)
qtyList.Add(qty)
dict.Add(unitCode, qtyList)
End If
Next
Next
End Sub
Hope that helps!
|
|
|
|
|
I was thinking of basically the same solution.
stevelk,
At then end of the process you need to write the contents of the dictionary out and you will have the desired combined results.
|
|
|
|
|
|
Hello,
I'm newbie in VB.Net(VB2010), maybe you can help me on my problem about the loading of data from SQL to text boxes on form load, and also i have created a button for navigation, inserting, delete, updating the record.
You have any sample code/form for this scenario. Hoping you can help me guys.
Thank You So Much.
Jon
|
|
|
|
|
jon2371 wrote: sample code/form
Nope. Sure don't. Not very likely that anyone is going to hand over a solution to you. It's expected that people try doing things for themselves and ask specific questions relating to a specific problem that they are having.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
There is lots of sample code, complete with details in the CodeProject Articles[^] section.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I want to change thye lcd display of a G510 keyboard.
I have looked but didn't find anyting in vb.net(2010). I foiund a lot of C but that I don't know.
Can someone point me into a good direction with samples in vb.net
I found 1 sample that reads part of the display.
Jan
|
|
|
|
|
jan212r wrote: I want to change thye lcd display of a G510 keyboard.
Coool project! There are .NET examples for the G15 keyboard, loved trying them. Loved it a bit less once I saw the price of the keyboard, and with no idea on whether the product would be continued, I dropped the idea.
You might want to download one of the examples for the older versions of the gaming-keyboard, they might be compatible. I doubt that anyone has an example-version that targets a specific keyboard in a language like VB, but you should be able to use the C#-libraries from VB. You'd probably also want the SDK, as it contains samples on how to set the display.
I'd love to see an article on this subject!
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy,
the price is not that high (100€ in Be)
the older models are compatible (normaly).
the sdk is free on download and on the site
there are no real libs. only 2 dll and almost no documentation
Jan
|
|
|
|
|
jan212r wrote: the price is not that high (100€ in Be)
Just noticed, did a quick Google. Thank you for the hint, wouldn't have looked for the current price without a small push.
jan212r wrote: the older models are compatible (normaly).
That's what I expect from Windows, but it's not always guaranteed with other manufacturers. I stopped working on it when I got doubts on whether the product-line would be continued in the future.
jan212r wrote: there are no real libs. only 2 dll and almost no documentation
There's a wrapper on CodePlex[^], an example on using it is here[^]. If you don't mind the German, there's also a P/Invoke-example on this[^] forum.
Working without docs is a bit harder, but also a bit more rewarding; I can imagine Logitech not putting much effort in .NET documentation for the display. A shame, since it's really a convenient technology, and IMO a better location for status-indicators than the tray-icon.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
thanks eddy,
Now I already have one test program. menu and response to the buttons;
I just need to find a good font.
Jan
modified 28-Aug-12 14:00pm.
|
|
|
|
|
jan212r wrote: Now I already have on test program
A working prototype, within a day, without much useful examples to work from
Would you consider writing an article on it?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
starting from the example you gived me 2° link
i addapted to this
Module Module1
Public LCD As LgLcd
Public fnt As New Font("Calibri", 8)
Sub main()
Dim conn As New lgLcdClassLibrary.lgLcd.lgLcdConnectContext()
Dim opn As New lgLcdClassLibrary.lgLcd.lgLcdOpenContext()
Dim bmp As New lgLcdClassLibrary.lgLcd.lgLcdBitmap160x43x1()
Dim nAllButtonsReleased, nButton As Integer
Dim bmpNet As Bitmap
Dim gfx As Graphics
lgLcdClassLibrary.lgLcd.lgLcdInit()
conn.appFriendlyName = "Test Application"
conn.isAutostartable = False
conn.isPersistent = False
conn.connection = lgLcdClassLibrary.lgLcd.LGLCD_INVALID_CONNECTION
lgLcdClassLibrary.lgLcd.lgLcdConnect(conn)
opn.connection = conn.connection
opn.index = 1
lgLcdClassLibrary.lgLcd.lgLcdOpen(opn)
Dim installed_fonts As New Drawing.Text.InstalledFontCollection
Dim font_families() As FontFamily = installed_fonts.Families()
Dim nCounter As Integer = 0
Do
Try
fnt = New Font(font_families(nCounter).Name, 10)
Catch ex As Exception
End Try
bmpNet = New Bitmap(160, 43)
gfx = Graphics.FromImage(bmpNet)
gfx.FillRectangle(Brushes.White, New Rectangle(0, 0, 160, 43))
gfx.DrawString(fnt.Name, fnt, Brushes.Black, 10, 10)
gfx.DrawString("Play Stop Prev Next", fnt, Brushes.Black, 10, 27)
bmp.hdr = New lgLcdClassLibrary.lgLcd.lgLcdBitmapHeader()
bmp.hdr.Format = lgLcdClassLibrary.lgLcd.LGLCD_BMP_FORMAT_160x43x1
bmp.pixels = New Byte(6879) {}
For y As Integer = 0 To 42
For x As Integer = 0 To 159
Dim trueColor As Color = bmpNet.GetPixel(x, y)
Dim nColor As Byte = CByte(If((trueColor.R = 255 AndAlso trueColor.G = 255 AndAlso trueColor.B = 255), 0, 255))
bmp.pixels(y * 160 + x) = nColor
Next
Next
lgLcdClassLibrary.lgLcd.lgLcdUpdateBitmap(opn.device, bmp, lgLcdClassLibrary.lgLcd.LGLCD_PRIORITY_NORMAL)
lgLcdClassLibrary.lgLcd.lgLcdSetAsLCDForegroundApp(opn.device, lgLcdClassLibrary.lgLcd.LGLCD_LCD_FOREGROUND_APP_YES)
Do
lgLcdClassLibrary.lgLcd.lgLcdReadSoftButtons(opn.device, nButton)
Loop Until nButton > 0
If (nButton Or 4) = 4 Then
nCounter -= 1
If nCounter < 0 Then nCounter = 0
ElseIf (nButton Or 8) = 8 Then
nCounter += 1
If nCounter > font_families.Count Then nCounter = font_families.Count
End If
Do
lgLcdClassLibrary.lgLcd.lgLcdReadSoftButtons(opn.device, nAllButtonsReleased)
Loop Until nAllButtonsReleased = 0
Loop Until (nButton Or 2) = 2
lgLcdClassLibrary.lgLcd.lgLcdClose(opn.device)
lgLcdClassLibrary.lgLcd.lgLcdDisconnect(conn.connection)
lgLcdClassLibrary.lgLcd.lgLcdDeInit()
End Sub
End Module
So I can see all fonts that works with button 3 and 4
and exit with button 2
button 1 is not used in the quick test program.
For all comments remember its quick and dirty just to find out how everythi ng works
thanks fo the help
Jan
Jan
|
|
|
|
|
jan212r wrote: For all comments remember its quick and dirty just to find out how everythi ng works
For a prototype, does what it should do; a short clean example that it works, and how.
Thanks for sharing the code
|
|
|
|
|
I come from C# world. Now I am in here and need a bit of help.
Here is a C# program which add event handler:
private CenterTrigger_EventHandlerAdv m_CenterTriggerHandler = null;
if (m_CenterTriggerHandler == null)
{
m_CenterTriggerHandler = new CenterTrigger_EventHandlerAdv(BRIReader_EventHandlerCenterTrigger);
m_BRIReader.EventHandlerCenterTrigger += m_CenterTriggerHandler;
}
I convert it to VB.net.
AddHandler m_BRIReader.EventHandlerCenterTrigger, AddressOf BRIReader_EventHandlerCenterTrigger
Now in VB, how can I check if an event handler has been added? If it has, I would like to RemoveHandler.
|
|
|
|
|
I would have a read of this
How to check to see if an event exists[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Simon_Whale,
Thanks for your answer. I read the article posted in your link. I get the answer after I have read the first paragraph of the third 'floor' of answer. The rest (fourth floor to the 7th floor) of article does not help me that much. (Actually I don't really understand those answers. )
Anyway, I just call RemoveHandler before calling AddHandler with the same set of parameters.
|
|
|
|
|
Visual Basic is a very forgiving and accommodating language. In keeping with the VB6 legacy, it does a lot of plumbing for you behind the scenes without ever writing a single line of code. You don't need to check if an event handler exists before calling RemoveHandler, just call it.
|
|
|
|
|
Hi
Can anybody help me in defining how to control the number of users logged in to the application. I have tried writing to registry of the server but it seems that is not a very good idea since then lots of security related concerns arise.
I have checked Google but not found any good method. I know there are many ways which can be used but I need a method by which it can be kept hidden from the user/ client administrator and also will not be removed once the software is uninstalled for future reference.
Because of the connection problem in MySql, which happens to be the back-end, I would like to have a method which I can bind into my application.
Any help in this matter will be highly appreciated.
|
|
|
|
|
To answer that, you'll have to define "logged in user".
Assuming your users are listed in the database; add a table that references the users, and which adds a timestamp. Add a record when a user logs in. This is the "login-time". You could add a second, which gets updated with every action (over a trigger), called "last activity".
Problem; users do not always log out as required. Computers die, networks die, hence, connections die without notifying that the user is no longer active. Solution; consider every user active with a login-time that's not older than "today", and a last-activity not older than an hour or two. Require the inactive users to log in again, and you're there.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy. I think this should be fine. The only problem is the second part of my query where-in I would like to keep a track of future installations. I would like to keep a track on whether this application is installable or not.
Anyway as a first step this is good enough. In case you have any other idea do please share.
Thanks again.
|
|
|
|
|