|
Its very easy, you can write your data to a simple csv file with comma as delemter...
for eg...
if you have data as
1 abc abc1
2 def def1
then
you can write this data as
open "somefile.csv" for output as #1
dim i as integer
for i = 0 to datagrid.count - 1
dim wline as string
wline = datagrid1(0).text & "," datagrid(1).text & "," & datagrid(1).text & vbcrlf()
output #1, wline
next i
close(1)
This is just a concept not actual code the purpose is to explain u just to add datagrid text to csv file..
thinking u know how to get data from the gridtable..
This csv file can then be opened easily in excel..
Hope this helps u in writing ur code.
Thanks!
Manoj Madhavan
|
|
|
|
|
I am using the datagrid in VB.net. How do I:
know when there has been a lostfocus on a cell?
manually change the value of a cell at runtime?
change the column width of each individual column?
|
|
|
|
|
I want to know the complete information of a Database...
how many tables it have what r there manes...
each table have how many attributes and what r there names......
and want to show it in a treeview...like this
TreeView1.Nodes(0).Nodes.Add(snode)
using OleDbConnection
i execute query like this
select * from emp
Table.Columns.Count
Table.Columns.Item(count).ToString
through this i came to know the column number and name
but want to know full information about a database.....
Nothing ...........................................................
|
|
|
|
|
hi
well i m working on visual basic...some days back i have installed one program on my computer , after uninstallation of that program i find out that the components are not shown....which were there in the project ( basically the activex control )...
now what to do....
i have reinstall the visual basic 6.0 version again and again ..but while selecting the activexcontrol option at the time of installation it didnt complete the installation ............and while without selecting the same option it installed the tool very comfortably......
My machine is windows NT 4.0....i have update that also.....but no +ve result
can anybody help me...........
With Regds
Vipin Bokariya
Sometimes the love we are looking for its just right in front of us - too close for the eyes to see. So close your eyes & let your heart see for itself
|
|
|
|
|
Hi Vipin ,
"....which were there in the project ( basically the activex control )..." - which project? the uninstalled program or a project u had before u installed the new program? which program is this?
try 2 register the activex components (by accessing their folder, highlighting and pressing enter on the keyboard). then open the project, access References or Components via Project menu. guess they'll show..
|
|
|
|
|
hi Vipin
it was bad to hear that u lost the active - X's that u used in the project.
Just try to figure out the components by reinstalling the app that u uninstalled, get the components copy them in a safe location uninstall the app again, then register the components.
Add the components in ur project and enjoy.
look for the solution its always next to u
|
|
|
|
|
I am trying to find a simple way to apply the same event handling to multiple object. For example: I have 10 lables that need to have a cursor change to hand while the cursor is moving over the object.
I would have to write the following for each lable:
Private Sub Label1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseHover
Me.Cursor.Current = Cursors.Hand
End Sub
Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
Me.Cursor.Current = Cursors.Hand
End Sub
Private Sub Label1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
Me.Cursor.Current = Cursors.Hand
End Sub
There's got to be a better way!
Thanks
|
|
|
|
|
jboss wrote:
2roses=? 14myw-14mym
Theas a beta way:
in vb.net, a sub can handle many similar events for controls of the same type
assume u hav label1, 2,.. labeln, guess this does it
Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter, Label2.MouseEnter, Label3.MouseEnter, .. , Labeln.MouseEnter
Me.Cursor.Current = Cursors.Hand
End Sub
Steff Kamush
2roses=? 14myw-14mym
|
|
|
|
|
|
I need to read a single sample of the audio mixer volume (recording) output. Is there any vb code for that.
|
|
|
|
|
I can't use certain key(ex:Enter key) for shortcut when the focus is on the datagrid.
I already tried to use the datagrid KeyDown events but it seems not work right. I must click the rowheader and then the Enter key(the shorcut I use) to fire the keydown event. If i don't do this the events seem not work even if i already use the command datagrid.focus() to focus to the datagrid. I also notice that i can't use the arrow key (Up and down key) to select the row i want. The triangle point at the row header move when i use the arrrow keys but again i can't use the shortcut (Enter Key) to make selection. It really bothers me to use mouse every time i want to make a row selected.
I'm also try several other method to accomplish this. I tried to use the form keydown events and already set the form KeyPreview property to true, I also tried to use the overrides PreProcessMessage function but the problem cannot be solved.
The last method I use is using the menu control and set each of the menu shortcut and it work great(it work for the whole form and this is the way i want it) but the shorcut is limited. I can't use the Escape key or the Enter Key.
how can i make a hotkey method to function just like the menu control does(cover the whole form or maybe within the whole application but not outside the application) and also take other shortcut which the menu control doesn't have? or perhaps you have other great idea on how to solve the problem.
Thanks.
|
|
|
|
|
I want to execute this command: "copy %1 lpt1:"
The reason I want to do this is because I have a file I retrieve from Unix and then I put a barcode in it by creating another file with VB and after that I want to send it to the printer.
Thanks for your help.
|
|
|
|
|
Ok I found the way.
Just in case somebody else would like to know:
use the Shell function.
Ciao
|
|
|
|
|
Hi all, I hope you enjoyed your weekend, but come on, its Monday now and I am back!!!!
I know you people aren't just sat on your backsides with nothing to do, but if you want a laugh, then I would really be most appreciative if somebody would take a look at an example system I have based a couple of articles on, and am planning a third.
The thing is, I like my approach, but I need to know that it would withstand close scrutiny. I am talking about my system of VisualThemes. But this system also implements my AutoSQL system, which connects objects to tables.
Its quite a significant piece of code, yet the concept is very simple to understand.
My question is really this...would anybody be god-like enough to volunteer to have me email them the code and then get on-line with me to discuss its merits. What would be good is to have the code up for viewiing, or executing and have a simultaneous chat eigher on Skype, ICQ or MSN Messenger.
This would help me shape my articles and ensure that the code I am offering is truly of value. I have putting stuff on here if people think that its done just for the sake of it. I truly believe that what I have to offer is well written, reusable and a great start point for many systems. It also spreads the practice of having deeply inherited standard objects which need little or no future maintenance, or that where a simple change is performed in a base class, that change delivers huge value to all derived classes.
Well enough b/s. Any offers truly would help me immensly, especially when judging my progress in adopting Dot Net technology.
I thank you for reading, and in advance, for your efforts.
If you would like to email me, you can drop a line to dev@bobbieandchris.com, all serious offers of help will be considered.
Nursey
|
|
|
|
|
you know, Combobox has property Drawmode = OwerDrawFixed
that allow us catch DrawItem events to brush color for each item in Combobox.
But a Textbox hasnot this usefull property.
Can you guide me how to brush color into a textbox?
special thanks!
dungti
|
|
|
|
|
Dungti,
If you are using VB.NET then just set the background color. If you are using VB 6 then you will have to work your way through this lot...It's on MSDN.
PSS ID Number: Q174301
Article Last Modified on 01-11-2001
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Visual Basic Learning Edition for Windows 6.0
Microsoft Visual Basic Professional Edition for Windows 6.0
Microsoft Visual Basic Enterprise Edition for Windows 6.0
Microsoft Visual Basic Control Creation Edition for Windows 5.0
Microsoft Visual Basic Learning Edition for Windows 5.0
Microsoft Visual Basic Professional Edition for Windows 5.0
Microsoft Visual Basic Enterprise Edition for Windows 5.0
--------------------------------------------------------------------------------
Summary
When a dithered color is selected as the background of a TextBox, the background around the text is displayed as a different, solid color when the display is set for 256 colors or less. To work around this limitation, you must hook the WM_CTLCOLOREDIT message and set the text background color to TRANSPARENT. This is not a trivial alternative, and using a solid background color is recommended if at all possible.
More Information
WARNING: ANY USE BY YOU OF THE SAMPLE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this sample code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
WARNING: Failure to unhook a window before its imminent destruction will result in application errors, Invalid Page Faults, and data loss. This is due to the fact that the new WindowProc function being pointed to no longer exists, but the window has not been notified of the change. Always unhook the sub-classed window upon unloading the sub-classed form or exiting the application. This is especially important while debugging an application that uses this technique within the Microsoft Visual Basic 5.0 Development Environment. Pressing the END button or selecting End from the Run menu without unhooking will cause an Invalid Page Fault and close Microsoft Visual Basic.
A TextBox control cannot draw text with a dithered background color, but it can draw text with a transparent background color. If the background of the control is dithered, this achieves the same visual effect. (Note the distinction between the background of the text and the background of the control. It is simple to get the control's background dithered; the problem is getting the text background dithered as well.)
From the SDK perspective, the answer is simple; handle the WM_CTLCOLOREDIT message in the parent and call SetBkMode() to set the background mode to TRANSPARENT. This is less simple in Visual Basic.
The following application consists of a form with a single Textbox control and a code module:
Create a new Visual Basic "Standard EXE" project.
Add a Textbox to Form1.
Paste the following code into Form1's code module:
Private Sub Form_Load()
gHW = Me.hwnd
Text1.BackColor = &HC0E0FF
Hook
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub
Add a module.
Paste the following code into this module:
Declare Function CallWindowProc Lib "user32" Alias _
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As _
Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As _
Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Declare Function SetBkMode Lib "gdi32" _
(ByVal hdc As Long, ByVal nBkMode As Long) As Long
Public Const WM_CTLCOLOREDIT = &H133
Public Const TRANSPARENT = 1
Public Const GWL_WNDPROC = -4
Global lpPrevWndProc As Long
Global gHW As Long
Public Sub Hook()
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
AddressOf WindowProc)
End Sub
Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub
Function WindowProc(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = WM_CTLCOLOREDIT Then
i = SetBkMode(wParam, TRANSPARENT)
End If
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, _
lParam)
End Function
Save the project, and then run it.
RESULT: When the form is displayed, you will see a TextBox with a dithered background. Type into the TextBox and the dithered background is maintained.
To terminate the application, use Alt-F4, the control box menu, or click the close button on the form. If you click the stop button in the Visual Basic Design environment, the Unload event is not triggered to unhook the window and an IPF will occur.
References
For additional information, please see the following article in the Microsoft Knowledge Base:
Q168795 : HOWTO: Hook Into a Window's Messages Using AddressOf
Additional query words: kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport kbControl
Keywords: kbGrpDSVB
Issue Type: kbhowto
Technology: kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB500Search kbVB600Search kbVBA500Search kbVBA500 kbVBA600 kbVB500 kbVB600 kbZNotKeyword3
|
|
|
|
|
Hi!
Thanks for your idea but my matter is that, I am using VB.NET
My background of Textbox is still COLOR.WHITE, and I would like to draw a small color rectangle first and then a draw my text (like you add each color beside each text item in a Combobox).
Could you give a new idea to handle this matter.
Special thanks!!!
dungti
|
|
|
|
|
I haven't even dipped my toe in the ADO water yet, but even so, I thought I would bounce this idea off you guys.
I have an object which contains 50 or so properties, of varied types likes strings, integers and the odd enumeration. I am getting pretty sick of the fact that everytime I think of a new property that can go on my object I have to write property acessors and then modify the database layout and then modify all the functions which add, delete and modify records.
I am working on a method that, so long as the columns in my table bare the same names as my properties I can enumerate the list of properties on an object and load the value for that property by fetching if from the .Items collection of a data record using the property name as the column name.
This means as soon as I add a new property and a new column my code effectively adapts to ensure that column or property are always loaded, saved or updated, without me having to modify any CRUD (create, read, update, delete) statements.
You are gonna tell me ADO does this and makes you coffee and predicts all the properties you want on your object using the ADO.CrystalBall.SeeFuture interfaces aren't yah!?
What do you think of the idea. I also thought it might be useful to create a new attribute which would exclude properties that you do not want to have handled in this way.
Thoughts and input, or other nice to haves are most welcome, as is all the scorn that this idea will create hahaha 8-)
Nursey
|
|
|
|
|
It works like a dream....
I just completely integrated this approach into my VisualTheme project, which serialises heaps of color information into an Access database.
Whenever I call my AutoBuildSQL function it returns a sql statement which satisfies the columnname=fieldvalue syntax of a SQL UPDATE statement.
This means I no longer have to write a function to specifically create a sql statement with all the column names and associated values, I just call my AutoBuildSQL statement and it returns a SQL statement with all the property names as SQL column names followed by an "=" followed by the property value...
Here's an example call....
Public Sub UpdateTheme()
If Not mConnection Is Nothing Then
Dim lCmd As System.Data.OleDb.OleDbCommand = mConnection.CreateCommand()
Dim lsSQL As String = AutoBuildSQL()
Try
lCmd.CommandText = "UPDATE Themes SET " + lsSQL + " Where Name = '" & Name & "' "
lCmd.ExecuteNonQuery()
Catch Fail As Exception
MsgBox(Fail.ToString & Chr(13) & Chr(13) & lCmd.CommandText, MsgBoxStyle.OKOnly, "UpdateTheme")
End Try
lCmd.Dispose()
End If
End Sub
The only caveat is that my real code doesn't save any properties that exist in the "THEME" property category (you know that wonderful attribute you can assign to properties). So as I said in my previous post, I should really create a new attribute called "AutoSQL" which will include the associated property in my automated data handling method, otherwise the property will be disregarded.
If this makes any kind of sense to you guys, and I hope it does, coz you are far better and more experienced than me at this stuff, then let me know if you think this is a good idea then I'll create it as a proper OO approach and generate a new article to post on here for all those interested parties to download and reuse.
Thanks for reading.
Nursey
|
|
|
|
|
Sorry to keep posting on and harping on, but I'm just getting so many good feelings about this approach. Even though its pretty simpistic, the amount of coding time it saves is pretty significant.
I am going to extend the idea so that it can automatically create tables in a database that match the layouy of the object, i.e it will create the appropriate columns with the matching types and data lengths as the properties on the object.
My Theme object now barely has a need to know anything about the database to which it is linked, which makes me feel pretty good as it can be changed by people to use SQL Server, Access, XML or text files with very little effort.
Nursey
|
|
|
|
|
Hi,
Is there any one to help me out using of Comm events in .NET.i just want to know which event .NET is equilant to "OnComm" event in VB6.or else tell me where exactly i would be able to get more info about Comm ,as .NET books are not covering this area.I would be eagerly waiting for some kind of help..
pls
|
|
|
|
|
If you are trying to use the Serial comm, for serial communication, I download a lib. that you can use just, tell me and I will sended to you.
ElRaptor
|
|
|
|
|
Hello Shihab:
I thing you are missing a line you need tell the library to read from the port and how many bytes your reding, this is the part of the code I am using to read:
Dim Cadena as string
' As long as there is information, read one byte at a time and
' Save it.
While (ObjComm.Read(1) <> -1)
' Save data read
Cadena = Cadena + Chr(ObjComm.InputStream())
End While
First I check If there is information to read and I tell the function to read only one byte, then I read the byte and I add the Character to a string.
You are using the InputStreamString, and if you look in the code this function uses the InputStream function to read each byte, I havent use this Property but I thing that you need to define the quantity of bytes to be read.
Hope this helps
JA
PS: Happy New Year!!!!!!
|
|
|
|
|
Hi all, hope you are having a bug free weekend!
I have attempted to write a function which scales and translates a graphics path.
If you describe a path as a square, I want to be able to draw your path twice...the first time using the size you specified in the path, then the second time I want to move it and reduce it (scale it down) by a specific number of pixels.
I attempted to write code to do this, but I fear my limited mathematical abilities are whats causing me to see rather odd results in size and position.
The thing is I DO NOT want to reduce the second drawn path by a percentage. I want to move it in by X,Y pixels then of course reduce its width by X*2 pixels and Y*2 pixels, so that the second shape always stays centralised with respect to the first. What this would mean is that I can have user defined button shapes, where I can maintain somekind of consistent look with pre-programmed rectangular and circular buttons which have gradient filled borders.
Can anybody offer me some code which produces a matrix that causes a translation and appropriate scaling factors to produce the required results? I think I only need the code to set the appropriate matrix properties, so you don't need to give me a big story. I will look at your code and probably see where my own is lacking.
Thanks in advance.
Nursey.
Nursey
|
|
|
|
|
I'm writing a macro that will tansfer information from a form in a Word documet to an Access database. I have parsed all the information I need into strings, and have found the automation commands for opening the Access database, I cannot figure out where to go from there.
Do I open a form in Access and use the form's controls to set the text of the textboxes? I cannot figure out how to set the point for the form or control from the Word macro. Is there a better way to do this?
|
|
|
|
|