|
You can also simplify your code by rolling up all the handlers onto 1 sub
e.g.
Private Sub ControlsClicked() handles control1.click, control2.click, control3.click
UserHasClickedForm()
End Sub
Even if your controls do something in their own click events, both will fire.
You could even remove the additional sub and attach the handlers directly onto UserHasClickedForm()
|
|
|
|
|
Thanks everyone for your help.
Using Dave Kreskowiak's and Luc Pattyn's suggestions for looking at other ListView events, with daveauld's suggestion for simplifying the code, I've gone from my bloat-code which didn't work, to the following elegant-code which does.
Public Class MyForm
Private Sub UserHasClickedForm() Handles Me.Click, MyLabel.Click, MyListView.MouseDown, MyListView.ColumnClick, MyButton.Click
MyLabel.Text="Clicked"
End Sub
End Class
- The MouseDown event is raised if you click in a blank area or Item of the ListView control, but not if you click on a column header if the View property of the ListView is set to Details.
- The ColumnClick event is required to handle clicks on the column headers.
Thanks again.
Paul
|
|
|
|
|
hi,
How to convert open office document to pdf in vb 6.0??
i think easily convert ms word to pdf format. but open office is very complex for conversion.
please give me the solution....
thx in advance..
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
hi,
i got a solution for this conversion...
its take lot of time...
Sub SaveAsPDF_demo()
Dim oSM, oDesk, oDoc As Object 'OOo objects
Dim OpenParam(1) As Object 'Parameters to open the doc
Dim SaveParam(1) As Object 'Parameters to save the doc
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
Set OpenParam(0) = MakePropertyValue("Hidden", True) ' Open the file hidden
Set oDoc = oDesk.loadComponentFromURL("file:///C:/tmp/testdoc.odt", "_blank", 0, OpenParam())
Set SaveParam(0) = MakePropertyValue("FilterName", "writer_pdf_Export")
Call oDoc.storeToURL("file:///C:/tmp/testdoc.pdf", SaveParam())
Set oDesk = Nothing
Set oSM = Nothing
End Sub
Public Function MakePropertyValue(cName, uValue) As Object
Dim oStruct, oServiceManager as Object
Set oServiceManager = CreateObject("com.sun.star.ServiceManager")
Set oStruct = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = cName
oStruct.Value = uValue
Set MakePropertyValue = oStruct
End Function
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
modified on Thursday, January 7, 2010 8:20 AM
|
|
|
|
|
In web forms - Is it possible to hide (visible=false) a complete row of controls with 1 command? And can this be controlled from code-behind? If so, pleasee show example...
Thanks in advance...
Chuck...
|
|
|
|
|
Ask this question in the ASP.NET forum.
|
|
|
|
|
I'm looking for a way to monitor drive activity using Visual Basic 2008. I want to create a small utility to simulate an LED in the system tray for drive read/write activity. I've found several such utilities that do this, but they all lack one thing or another, or they are over bloated with stuff I don't want or need, etc. I want to write my own so it will be like I want it. To get started, I need to know how to monitor drive activity. Can anyone point me in the right direction?
Blessings
RevEd
|
|
|
|
|
You'd need a device driver (.dll) that runs in Ring 0 that intercepts all I/O calls to do this. You cannot write this part in VB.NET. It MUST be done in C++ or some other unmanaged language.
|
|
|
|
|
You could look into ETW (Event Tracing for Windows)which is used to trace
Kernel/System events (XP or higher) and comes with a high performance
provider to (Kernel) Disk IO tracing. MSDN[^]
However, any docs I have looked at are targetted at a C++ audience like Dave said above...
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
|
Here's the answer: From bdbodger at MSDN (and also Dmitry Vitkovsky here at the Code Project)
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/62900f1e-1969-49bb-92cd-4c4eb8c7456d/?prof=required
Create a form and add 2 PerformanceCounter controls . For the first one set Catagory property to LogicalDisk , CounterName to Disk Read Bytes/sec , InstanceName to _Total for the second PerformanceCounter set CounterName to Disk Write Bytes/sec and the other values the same as the first PerformanceCounter . You will need to create 4 small images that you will use with a notifyIcon and add them to your resources such as these
<some graphics shown here>
Set the form WindowState property to Minimized and the ShowInTaskbar property to false . Add a timer set it's enabled property to true , interval 100 and add a NotifyIcon . Then try this code
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim both As Integer = 0
If (PerformanceCounter1.NextValue > 0) Then
both += 1
End If
If (PerformanceCounter2.NextValue > 0) Then
both += 2
End If
Select Case both
Case 0
NotifyIcon1.Icon = My.Resources.blue
Case 1
NotifyIcon1.Icon = My.Resources.green
Case 2
NotifyIcon1.Icon = My.Resources.green2
Case 3
NotifyIcon1.Icon = My.Resources.greengreen
End Select
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NotifyIcon1.Icon = My.Resources.blue
End Sub
Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
NotifyIcon1.MouseClick
If e.Button = Windows.Forms.MouseButtons.Right Then
NotifyIcon1.Visible = False
Application.Exit()
End If
End Sub
End Class
____________________________________________________________________________________________
Change InstanceName to monitor a particular disk drive .
Blessings
RevEd
|
|
|
|
|
Hi,
I am facing a critical problem with office version. I am not sure but this happening in my side.
I have developed a vb.net application of outlook add-in which integrate with outlook. Using this i am syncing contact from server and add onto outlook.
I am using ms access as a back end for saving contact information also. I have a Boolean fields in ms access table. My application is working fine. but in some OS Version and Office Version it is updating some contact automatically. I run my application in following OS with Office version which is given in Table below.
The Third column is my output in different machine. I am not updating contact but in window 7 and office 2007 this is doing automatically. First 3 rows is working fine according to my logic. but 4rth row is showing wrong output.
OS Version, Office Version , Boolean Fields Update Automatically.
Window XP, 2003, No
Window XP, 2007, NO
Window 7, 2003, No
Window 7, 2007, Yes
Please guide me where i am wrong and what i need to do.
Regards
Dharmchand Dhingra
|
|
|
|
|
I've got an Access Database
For whatever reason, there is a field in there for DATE that is declared as string.
Also there are 3 other fields in there called FDAY,FMONTH,FYEAR that are declared as number and actually get the parsed values from the DATE field.
So if the user enter for DATE 21/12/2009, the FDAY=21, FMONTH=12, FYEAR=2009
Now at some point, the user wants to get all the records from 20/6/2009 - 12/12/2009
Can someone help, on how we can make an SQL query to do that ?
Whatever i have tried does not solve the problem.
It is easy, as long you have the same month and year in the "FROM" and "TO", because you just check the FDAY variable to be within the limits.
For example if we wanted from 5/10/2009 - 23/5/2009, the SQL would be "SELECT * FROM TABLE WHERE FDAY BETWEEN 5 AND 23"
However the things get complicated when you have different month or year.For example if we want the records from 5/6/2009 to 23/11/2009.
Now what ?
Don't ask why the date field is declared as STRING and not DATE, in the first place.
The question is, is it doable with what we have now ?
Thanks.
|
|
|
|
|
Hi,
I would attempt this:
SELECT * FROM table WHERE STR_TO_DATE(stupidDateField, format)>=startDate AND STR_TO_DATE(stupidDateField, format) <=endDate
Where you need to replace "format" by whatever code suits your app, see http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date[^]
PS: it would be wise to rework your datebase so it stores real datetime information, not strings, as they will make life more difficult all the time.
PS2: startDate and endDate, when literals, again make date formatting problems sneak into the situation; I am not sure parameterized SQL is possible with Access, if it is, you better use it.
|
|
|
|
|
You can reformat the date to use ANSI format so they can be compared correctly. For example, use a query similar to this:
SELECT *
FROM Table
Where format(fyear,"0000")+'/'+format(fmonth,"00")+'/'+format(fday,"00")>='2009/06/05'
and format(fyear,"0000")+'/'+format(fmonth,"00")+'/'+format(fday,"00")<='2009/11/23';
Note that the begin and end date have to also be formatted to use ANSI format: "YYYY/MM/DD".
It's not pretty but because you don't have control over your table structure, this may be the solution to your problem.
Happy programming!
|
|
|
|
|
Thanks, that did it !!!
I should know better about this SQL
|
|
|
|
|
HI,
how to open existion file (all type of files)without open dialog box.
i have mention file location in programmatically,its automatically fetch the file from specific path...
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
Dim strBuff As String
Open "c:\errorlog.txt" For Input As #1
Do
Line Input #1, strLine
Debug.Print strLine
Loop
Close #1 It would be better to use the FreeFile function to get a free number instead of hardcoding a #1, but I'm lazy today
I are Troll
|
|
|
|
|
...in a method called by a property within an object that is one of over 68,000...
In my 30 years of programming, I've never once experienced a stack overflow, until today.
Each time I run the program, the exception is thrown at a different spot.
I'm in hell.
EDIT ============
I moved about 60 lines of code from within a property to its own method, and had neglected to change some variable names to coincide with the move. The property was doing something like this:
Public Property Total As Decimal
Get
'do some stuff
Total = Total + x
End Get
Every time it referred to Total on the right side of the = operator, it ran through this property code again. In essence, it was a recursive method.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Tuesday, January 5, 2010 4:43 PM
|
|
|
|
|
Was this meant as a question or a comment?
John Simmons / outlaw programmer wrote: In my 30 years of programming, I've never once experienced a stack overflow, until today.
Wow, either you're a really good programmer or you must not have written many recursive functions in that time.
|
|
|
|
|
I think it's more luck than anything else. And yes, I've done my fair share of recursive functions.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi All,
The Requirement is like this
I have to Set a Color to ComboBox as Red when Style is Other than DropDownList. How can it be possible in VB.Net. Also it should not be Editable and should be Read Only.
Code:
-----
'Combo Style is DropDown Here
ComboBox1.Items.Add("One")
ComboBox1.Items.Add("Two")
ComboBox1.Items.Add("Three")
ComboBox1.BackColor = Color.Red
'Items in ComboBox are able to Edit!!! which should not happen.
But ComboBox1 BackColor is Red which is OK for Me.
I dont want to Edit the Items in Combo, How it is Possible.
Please give me a solution for this.
Thanks & Regards,
Uday.
modified on Tuesday, January 5, 2010 1:18 PM
|
|
|
|
|
RTFM my friend. The help in VB.NET says "If you set the DropDownStyle property to DropDownList, you can select only valid values from the list. If you set the DropDownStyle property to DropDown, you can type any value in the editable area of the ComboBox."
You said "Style is Other than DropDownList" Why would you want to do that when DropDowmList does the job??
Please ask your homework questions somewhere else.
(As a PS: Thinking about this you could mask the edit area - but not the drop down arrow - with a transparent label, which you could hide when in the correct mode and you can't edit anyway, but it all seems a bit daft to me!)
modified on Wednesday, January 6, 2010 10:16 PM
|
|
|
|
|
Hallo,
I am developing an application where there is a source which sends UDP datagrams at a constant Interval (2 datagrams per second). I am receiving these datagrams in the following code:
EP = New IPEndPoint(IPAddress.Any, clsUDP.nListenOnPort)
' clsUDP.nListenOnPort=6466
UDPInput = New UdpClient(EP)
While clsMisc.ListenforUDP
Try
byt = UDPInput.Receive(EP)
..................
Catch ex As Exception<br />
MessageBox.Show(ex.ToString)<br />
<pre>End Try</pre><br />
End While
UDPInput.Close()
UDPInput = Nothing
EP = Nothing
the flag clsMisc.ListenforUDP is true as long as the application runs. This is set to false when an user Logs off.
This is working properly when a user logs in and logs off three times consecutively. But when an user logs in fourth time. I found out by debugging that the program hangs
after
byt = UDPInput.Receive(EP)
this line. I have also tried with asynchronous connection (Beginreceive and end receive) and also with
UDPInput.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 0) to flush the buffer before I read the byt but in vain. It is always the fourh time that the problem arises.
I am trying this to solve for the last 3 days without success. I shall be grateful if somebody helps me.
Thanks.
Roy
|
|
|
|
|
When your user logs off are you objects being properly released and disposed.
looking at the mess you have above, you have;
UDPInput.close()
UDPInput = Nothing
EP = Nothing
You may be thowing an exception trying to close the object, which then bombs because it is in a state that cannot be closed.
You should test to see it is open and/or isnot nothing before trying to close.
|
|
|
|
|