|
You should have event handlers defined in your class library. You register those event handlers with the Form events. When the event is fired(from the Form), all event handlers registered will be invoked. Since your class library had registered, its event handler will also be invoked.
|
|
|
|
|
Hi i have a problem that is making me scratch my head until it hurts.
Hopefully someone can help. Well in my project I have a graph were I plot information from a database. Anyways, when I draw my data to the screen I add each point to an arraylist. I use an arraylist since the number of points can vary. So I have my points drawn on screen so next is were my problem comes in. What I want to happen is when the mouse pointer goes over any of my points on my graph, then a small box pops up with more information. So in my mousemove event I have code as follows
For Each p As Point In myCoordinatesArrayL
gPath.AddEllipse(p.X, p.Y, 30, 30)
If gPath.IsVisible(mouse.X, mouse.Y) Then
'Then make my small window pop up
Else
'Do nothing or close small window if its up
End If
Next
So im taking the points from my arraylist and adding an ellipse to a graphics path. Then I check
the graphics path 'IsVisible' function if the mouse's x and y are over it.
I have mixed results with this so far. Some strange and unexpected things have happened. I can get the window to pop up but sometimes it doesn't. I have done a bit of error checking were I have placed two labels on my form and I increment a number when ever the mouse is not over the points and then increments the other number when the mouse pointer is over the point. This has unexpected results such as when I have only one point on the screen and i move the mouse over the point then both label increment and when i have more than one point on the screen, its works as expected except for the first point on my graph where is produces the same problem.
Hope you can make sense of this. Is there a better way to do what im trying to do. Any suggestions.
Thanks for your help
|
|
|
|
|
You creating an ellipse for every point in the graph every time the mouse moves?? Wouldn't it be easier to just track the mouse movement, mapping it to the closest point in the X axis, then just create the one ellipse to see if the mouse is in it?
Also, the code looks incomplete. Are you Disposing the GraphicsPath you created when you're done with it?? Are you creating a new one every time you iterate through this loop?? You don't need to.
|
|
|
|
|
Hi,
Not sure I know what you mean. So i think that for every point in my arraylist that I should
check its x coordinate against the mouse x coordinate and then if it does , then i should add the ellipse to my graphics path. This is what I've tried but its not really working for me
For Each p As Point In myCoordinatesArrayL
If p.X = mouse.X Then
gPath.AddEllipse(p.X, p.Y, 30, 30)
If gPath.IsVisible(mouse.X, mouse.Y) Then
'code for displaying my window
End If
Else
'do nothing or close my window
End If
Next
I dont have code to dispose the graphicsPath here but in my forms closing method. Is this right
Thanks for your time
|
|
|
|
|
No, you have to do a little math to figure out which point the X coord is NEAREST to on the graph. In your method, the mouse has to be EXACTLY on the point your looking for, not around it.
If you have 3 points on the graph at 50, 75 and 100, you take the mouse X coord, say 80, then check it against the X coord of the points on the graph, plus or minus say 10. Doing the math is FAR faster than creating a graphics path to do the test for you.
For Each p As Point In myCoordinatesArrayL
If p.X - mouse.X <= 1- Then
' You don't even need the GraphicsPath since you just
' found the point you're looking for!
' If you really needed to, you can do the same test for the Y coordinate in here.
End If
Next
|
|
|
|
|
Thats great. Thanks for your help. Never even thought of that. My inexperience is showing anyway.
Thanks again.
|
|
|
|
|
i m student and making a project for my college
it is compulsory tat i make the project in vb6
The project is tat i have to make an application using vb6 in which we just have to mention the file name which we have to search
and click a button and it will search in all computers in lan at once
we dont have to mention any computer name or host name it should take the computer names itself
i have written the code in which i have to mention the hostname plus drive
for eg: \\rng13579076\c$
the alternate way is to search neighbourhood network and i will get all the computers connected in lan but i dont know how to do so
pls guide me!
purvas
modified on Saturday, February 21, 2009 4:07 AM
|
|
|
|
|
spruha369 wrote: for my college
it is compulsory tat i make the project in vb6
VB6 isn't the appropriate choice for students anymore. It's not for sale (only on eBay) and tech support from MS is expensive. There are still some old applications running under VB6 (or even VB4 for that matter), but it would be pointless to learn something that has been proclaimed "dead" last year. Can you ask your teacher why you'll have to learn a dead language? I'd love to hear the reasoning behind it
If you are left with no options but using the old IDE, ask if you're allowed to write some of the logic in a newer language - you could do the hard parts in VB.NET or C# and hook it up to the old application.
Good luck!
I are troll
|
|
|
|
|
Hi,
How can I iterate all of the directories in a specific drive? My patience is exhausted and my hair is all over the table. My aim is to get in and get out evey directory in selected drive. If the directory has some files with the extension of (txt) I should put their name into listview.
Currently I can read all 1st child directories under the specific drive. But we don't know how many child directories has the targeted one. Therefore we should be able to skip from one to another one. When there is no directory and no file we should go back to their parent and continue to process until the last child directory gets done.
I am seeking a sample with use of directoryinfo. I didn't want to put my code here because it is quite long.
I would really appreciate it if you know the method or having the code.
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
|
Thanks
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
If you want every directory on the drive, you will need to use recursion. Recursion basically looks something like this:
Public Sub CheckDirectories(ByVal root As IO.DirectoryInfo)
For Each file In root.GetFiles("*.txt")
'process the file
Next
For Each subDir In root.GetDirectories()
CheckDirectories(root)
Next
End Sub
which you then call with the DirectoryInfo for the selected drive to start the whole thing.
|
|
|
|
|
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hi Gideon
I am interested with your approach, I know what do you mean by "something like this", it needs a little fine tuning.
I had this code which is stayed in forever loop and I could not tell why?
' Command Click
Dim RootDir As New IO.DirectoryInfo("C:\MyFolder")
Call Module1.CheckDirectories(RootDir)
' Module1.CheckDirectories
Public Sub CheckDirectories(ByVal root As IO.DirectoryInfo)
For Each file In root.GetFiles("*.txt")
Debug.Print(file.Name) 'process the file
Next
For Each subDir In root.GetDirectories()
CheckDirectories(root)
Next
End Sub
TIA
Samir R. Ibrahim
|
|
|
|
|
Hi Samir,
I assume you are seeing the names of the files within c:\MyFolder displayed ad infinitum. Take a good look at the actual recursive call within the method, i.e. the point where CheckDirectories calls itself, and think what the parameter should be for that call.
Step through it with the debugger if you still can't see what's wrong.
Alan.
|
|
|
|
|
Hi Alan
Alan N wrote: and think what the parameter should be for that call.
subDir
I know that, but I was testing you.
Thanks for pointing to it
Samir R. Ibrahim
|
|
|
|
|
Well that's the question. I try to play an avi file with more than 1 audio track and always hear all the tracks simultaneously.
I wanna choose and hear only one of the audio tracks, but I don't really know how to do it.
Thank you in advance.
- I've seen some similar examples here, but I didn't find anything for VB .NET 2005
If there is already a thread about this subject I'm really sorry, didnt find it.
|
|
|
|
|
I didn't know there was such a thing. If you can play any track how you want in Windows Media Player, you can then use it's control to do it inside your app.
|
|
|
|
|
I've tried Windows Media Player and DirectX.AudioVideoPlayback, both played the video fine, but also played all the audio tracks at the same time.
You can't choose one sigle audio track in a multi-track avi file with WMP (Not even with WMP 11)
|
|
|
|
|
Ok, I've found a way to do it.
First of all you have to install a DirectShow filter to 'separate the audio tracks'
I've used Morgan Stream Switcher filter (freeware)
And then:
Dim iControl As WMPLib.IWMPControls3 = WMP.Ctlcontrols 'WMP.Controls if you didn't embeded the object
icontrol.currentAudioLanguageIndex = track 'Where track is the audio track index.
And thats all.
|
|
|
|
|
Hi, I'm helping a colleague of mine.
We're trying to create an Excel workbook so he can do some calculations. However, we can't get the excel object to instantiate. We've added the reference via 'Project->Add Reference->Microsoft Excel 11.0 Object Library->OK.
On our form, we've added the following but can not get the object to instantiate.
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim excelapp As New Microsoft.Office.Interop.Excel.Application
Dim excelwb As Microsoft.Office.Interop.Excel.Workbook
End Class
The Dim calls seem to take ok as no squiggly lines appear on those two lines.
Attempting to reference excelapp or excelwb only results in squiggly lines under their names and no properties will appear in the drop down - that is, there is no dropdown as it doesn't recognize the two variables.
How can we instantiate the excel object so we can use the methods on it?
Thanks in advance.
|
|
|
|
|
I tried the following;
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim excel As New Microsoft.Office.Interop.Excel.Application
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
excel.Visible = True
End Sub
End Class
And excel application opens fine and becomes visible when Form1 loads.
If you put excel.visible in your form load event as a test does that work?
|
|
|
|
|
Ah, I see what we did. We were trying to invoke methods on the vars without being inside a form-method.
(I'm not a VB.NET developer. Can you tell!?) :P
Thank you very much for your help!!
|
|
|
|
|
I am using MS SQL as my database.
To display my data in a datagrid i used the SqlDataAdapter, SqlConnection and its DataSet to connect to my database.
When i preview my data through the SqlDataAdapter its just fine.
But this will not work for the datagrid.
I used
jesSqlDataAdapter.Fill(jesDataSet1)
or
jesSqlDataAdapter.Fill(jesDataSet1, "Table_Name")
in the form/datagrid load sub.
However i get an error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information:System error.
Please help.
|
|
|
|
|
From the very limited information you provided, it looks like the SQL query you tried to run isn't valid, or how you setup the query to execute isn't correct.
|
|
|
|