|
You can use rwestgraham's method to get the window handle, or you can do it the easy way and just use the value that's in the form's hWnd property.
Dim windowHandle As Long
windowHandle = Form1.hWnd
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for the easy way to get the handle to the app form.
what I'm trying to do in my app is dynamically size the label.width of a prompt and the text.left of the data next to it, that the user edits. i believe i need to get the TextMetrics for the selected font to calculate the widths and left positions. There's probably an easier way to do this too.
+----------+--------+
|first label: |first text|
+----------+--------+
+-------------+-----------+
|second label: |second text|
+-------------+-----------+
|
|
|
|
|
The GetTextExtentPoint32 API will return the length of a string in points, which can then be converted to pixels or other units to size a Textbox control to fit the text. You can easily size a Label control to fit it's text by simply setting the AutoSize property to True.
Robert
|
|
|
|
|
I also want to run my program from a cd, any suggestions?
rives
|
|
|
|
|
I'm trying to add a tab control to my form, and I did that, now i need to code it, does anyone have any sample code for that form.
rives
|
|
|
|
|
Hi!
What do you mean by code it?Add TabPages?
Create a TabPage objects, assign some text to the Text property and then do TabControl.Controls.Add(myTabPage) and the tabControl will have a new tabPage.And so on...
dim myTabPage as New TabPAge
myTabPage.Text = "Tab1"
(...)
myTabControl.Controls.Add(myTabPage)
Never say never
|
|
|
|
|
|
looks very critical problem...
|
|
|
|
|
or very critical boy
moreover it's his first post !!!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Does anyone know how i can calculate the average of all the integers in a column in a SQL table using vb code?
|
|
|
|
|
this sql statement will do the trick...
SELECT AVG(int_column) FROM your_table
// TODO: Write code.
|
|
|
|
|
This is exactly what i needed but i have a few questions.
does the "int" in int_column have to be there?
How do i get this value through code and save it to a variable?
How do i display this average value in a textbox or messagebox?
|
|
|
|
|
No, int_column was what I used to mean your Integer Column.
And for the rest of it...
<br />
Imports System.Data.SQLClient<br />
...<br />
Dim conn as SQLConnection<br />
Dim cmd as SQLCommand<br />
Dim str as String<br />
<br />
conn = New SQLConnection("server=localhost;uid=sa;pwd=;database=yourdb")<br />
conn.Open()<br />
cmd = new SQLCommand("SELECT AVG(int_column) FROM table")<br />
str = cmd.ExecuteScalar().ToString()<br />
<br />
MessageBox.Show(str)<br />
I don't know if that is exactly right, but it's a good place to start from. Here is some light reading to fill in the blanks.[^]
// TODO: Write code.
|
|
|
|
|
That is exactly what i needed.
Thank you
|
|
|
|
|
Does anyone have any experience with msgboxresult
I have a yes or no message box that comes up when the user
clicks the Delete All button. When they click yes i want to run
my DeletAll() sub but if they click no i do not want anything to happen.
Here is my code but when i run it, it will delete all no matter which button
i push.
msgbox("Are you sure you want to delete all records? ", msgboxstyle.YesNo, "Delete All Records?")
If msgboxresult.yes then
DeleteAll()
Else
Exit Sub
End If
|
|
|
|
|
Yeah here you go:
<br />
If msgbox("Are you sure you want to delete all records? ", msgboxstyle.YesNo, "Delete All Records?") = msgboxresult.yes then<br />
DeleteAll()<br />
Else<br />
Exit Sub<br />
End If <br />
OR
<br />
Dim msgRes as msgboxresult<br />
msgRes = msgbox("Are you sure you want to delete all records? ", msgboxstyle.YesNo, "Delete All Records?")<br />
<br />
If msgRes = msgboxresult.yes then<br />
DeleteAll()<br />
Else<br />
Exit Sub<br />
End If <br />
// TODO: Write code.
|
|
|
|
|
Thank you, i didnt think of doing it that way.
I actually ended up doing it like this
select case msg(...............)
case msgboxresult.yes
DeleteAll()
case msboxresult.no
end case
|
|
|
|
|
I had an application handed to me that get the 'privilege' of fixing. This is a vb.net web app that is leaking memory like none other ( ok ok... it's leaking references to objects... fact is it's using up 2gig of memory when it should be using 40Meg).
I'm having a heck of a time locating the source of the memory leak. It is a medium sized application ( about 30,000 lines of code ). Any Ideas on where I should start looking? I see the following lines of code repeated many times over... anything in here look like a memory leak to you?
<br />
Catch ta As Threading.ThreadAbortException<br />
Catch ex As Exception<br />
Throw New ApplicationException("Error Retrieving Area Types", ex)<br />
<br />
Finally<br />
If Not dbConnection Is Nothing Then<br />
If dbConnection.State = ConnectionState.Open Then _<br />
dbConnection.Close()<br />
dbConnection.Dispose()<br />
dbConnection = Nothing<br />
End If<br />
<br />
End Try<br />
// TODO: Write code.
|
|
|
|
|
Well it sounds good. If you could explain about your application then it would be much better for us to guide. other wise we can say just start from there....
Do one thing ... at the end of every event ,Procedure , Function write
GC.Collect()
this will collect the garbage which your system is not releasing. Secondly if you are using datasets and datatables then close them and set them to nothing after using them and right after that write GC.collect line to collect the garbage. I am sure this will help you out and will brought you back to the orignal memory.
|
|
|
|
|
I forgot to include some more info...
I have tried using GC.Collect()... it does not seem to release the memory... it just promotes most of it to Gen2 ( Gen2 will show around 500MB after 2 hours of 14 users using the app ). So the references are still alive somewhere. I'll try closing the datasets.
Datasets are used extensively throughout this application. The application is an asp.net interface to a large database.
The biggest memory hog appears to be the forms for data entry. The forms have up to 70 different entry fields with some of them being drop down lists that are populated by the database. The drop down lists are cached in a hash table.
// TODO: Write code.
|
|
|
|
|
well from your point I am quite afraid that you are might be using wrong queries. like to fetch ID from Table you are using select * from Table... and then you are puting them in a session to save them from fetching again. if it is true then dont do this. try to destroy maximum memory at server side MANUALLY ... instead of waiting
like
DataTable or Dataset.Dispose()
GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
GC.Collect
means destory every thing... second thing is how many session variables you have and how many of them are datatables and datasets etc..... like asking for the variables which can consume unlimited space... Same with the application level variable....
hope this will help and let me know if nothing goes fine....
cheers......
|
|
|
|
|
I have inherited a data-access UI project in need of a bit of work. Currently, there is an MDI parent form, and a single form available as a child form. Within this child form, there are about 20 fairly complex panel containers -- each with a variety of controls (labels, textboxes, comboboxes, etc.) -- which are either moved offscreen or rendered invisible to give the impression of multiple forms.
My instincts tell me that the panel approach is a poor strategy (and a royal pain when it comes to design changes), and I want to pursue a fuller implementation of the MDI foundation in place, but I need some convincing arguments to demonstrate how this is a more stable approach, and not a waste of time.
Any suggestions/ideas would be greatly appreciated.
Thanks!
|
|
|
|
|
Hi Stew,
I'm not sure if this will convince you, but I have dealt with this same situation in developing my own applications that have many different forms with similar uses.
If you are designing a simple application that will not be developed any further (no future expansion or additions) then one big form could be useful because all of the functionality you will ever need is right in front of you, without having to switch from form to form.
Chances are your will at some point need to add to this design, be it new features, new controls or just a new look.
I would suggest always using the MDI format as it has proven to be the most reliable when upgrading existing forms. I live and code like this due to a very helpful acronym I adopted from my years in the Marines, K.I.S.S. (“Keep it Simple Stupid”). Simple is usually always the better route unless you just can’t do more with less.
Even though areas of a form may be in panels, there is always some distinct use for that panel from the rest of the panels on the form. In other words, it should prove beneficial to choose the MDI approach when designing an application. It is better to repeat very subtle similarities on different forms then to maintain all of the code on one gigantic form.
You can also create your own user controls that contain repeatedly needed functionality, then simply place the user control on any form you need to use it from.
Hope my tangents didn't do more harm them good,
Scott Page
|
|
|
|
|
I created a payroll program that will generate hours and tax deductions. I would like to print the results. How can I do that?
bravo659
|
|
|
|
|
You need to create a report. VB.NET comes with crystal reports and they are easy to create but hard to deploy. Other guys in here talk about XML and .CSV but i am not too familiar with either for reporting purposes.
|
|
|
|