|
You are absolutely correct, I could shave all of that "extra" stuff off, and have cleaner code with much less lines of code that could go wrong. But it hasn't changed the actual return value. And you are correct I am not fully versed in Virtual memory values, THAT is why I am asking for help.
Dave Baker
DB_Cooper1950
"Life is like a box of..."
|
|
|
|
|
OK. The memory functions under My.Computer.Info are actually calling a Win32 API function called GlobalMemoryStatusEx[^]. This function fills a structure called MEMORYSTATUSEX[^] that lists various measurements of the various types of memory managed by Windows, from the CURRENT PROCESSES point of view! This means that it measures memory based on your applications view of it, not the System Wide Windows view of memory! There is a HUGE difference...
When you call TotalPhysicalMemory and AvailablePhysicalMemory, you get the amount of physical memory reported by Windows, admittedly system-wide. But, this is NOT nocessarily all the physical memory in the machine. Some of it can be reserved by hardware for other functions, like shared video RAM.
Calls to TotalVirtualMemory and AvailableVirtualMemory return the status of YOUR processes virtual address space, which can be MORE than the amount of physical RAM available to Windows. You can typically have 2GB of memory available to each process, even though your machine only has say, 512MB of physical RAM.
How?? That's where the pagefile comes in. (Warning!! This explaination is very simplified!!) The pagefile is NOT virtual memory, but is a file that is used to store pages of memory that are allocated by all processes running in the system, combined. Say your machine has 512MB of RAM. The default pagefile size is 1.5x that size, or 768MB. So, if nothing is changed, Windows can have up to about 1.2GB of memory allocated acrossed all processes running in the system. But, it can only have 512MB of code and data in memory at any one time. Anything that is not being used, or the oldest memory pages that are still dirty, is swapped out to the pagefile to make room for pages that are needed.
WHen you launch your process, it gets a new virtual address space of 1.2GB. There are user-mode (for your application) and kernel-mode portions of that space. After all, you still need to be able to call into the Windows Kernel to do stuff, like open a file, and that Kernel code sits at the bottom of your VAS. Say the Kernel uses 200MB of memory. What's left, 1.0GB, is your user-mode space. This is what your application has left to allocate memory from.
Every process gets it's own virtual address space. Each process thinks that Windows and it are the only things running on the machine as far as memory goes! Each process thinks it gets about 1GB of RAM to play with, even though there is only 512MB in the system. Get it?
Now, if you called TotalVirtualMemory, it'll return something around 1GB. It only looks at the user-mode portion of your processes virtual address space, ignoring the kernel-mode portion. This is the value that your seeing in your code! I hope you can now see why there is no such thing as TotalVirtualMemory acrossed the entire system.
But, remember that pagefile size of 768MB? Well, there IS a limit to the amount of memory that can be allocated system-wide. If 2 processes tried to allocate 1GB of each, one of them would fail, even though it's address space says it can! Why?
Well, in our example, the pagefile can only hold 768MB worth of memory pages. Combined with physical memory, all the processes in the system can only allocate up to 1.2GB of memory, combined! Because of this, regardless of the virtual address space your process has, it's entirely possible that a process with a 1.2GB virtual address space can fail when it tries to allocate an object that takes 4KB of memory! Even though AvailableVirtualMemory said there was more...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave,
Thank you VERY much for that explaination, it makes a lot more sense to me now as to why I am not getting the exact amount of virtual memory that I thought that I was looking for. I realize that the explaination you gave was a simplified, but the point that you were trying to convey, was easier to understand that way, and for that I am grateful.
David Baker
DB_Cooper1950
"Life is like a box of..."
|
|
|
|
|
is there any control or functionality of any control that i can use to display data in hierarcal structure with multiple text boxes associated with each node? This is Very Urgent....
TC
-- modified at 9:19 Friday 27th October, 2006
|
|
|
|
|
Short of creating your own I'd say look at using a TreeView control with the LabelEdit property set to True.
|
|
|
|
|
But doing this , i have only one textbox on node and i want more than one textbox associated with each node. what to do?
TC
|
|
|
|
|
|
is it posible to add more than one textbox horizontally with each node? if yes then how?
TC
|
|
|
|
|
I had created application using VB 6.0 and Crystal report 8.5.
I want to install this application on client system, which does not have VB 6.0 and crystal report installed.
For VB application I will use deploymnet and package wizard.
But for crysatal report - how can I create set up.
Yor help is appreciated.
Thanks in Advance.
Kumar
-- modified at 3:25 Sunday 12th November, 2006
|
|
|
|
|
Good Day everyone,
i would like to ask for you help guys, i want to create a programs about
the circle packing, but dont know how to start with this, how can i draw equal circle without overlapping inside a bigger circle, i googled it but the result is discrete mathematics, im not a "math guy", so i cant understand those symbols..:=), thanks in advance for your help.. and GOD BLESS...
Kenshee
|
|
|
|
|
You'll want to use methods exposed from the Graphics Class[^] in the System.Drawing namespace.
Below is a quick sample I threw together - is this what you mean? Paste this code into a new form & run it.
Public Class Form1
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Me.Paint
'draw three circles over each other
e.Graphics.FillEllipse(Brushes.Red, New Rectangle(0, 0, 300, 300))
e.Graphics.FillEllipse(Brushes.Blue, New Rectangle(25, 25, 250, 250))
e.Graphics.FillEllipse(Brushes.Green, New Rectangle(50, 50, 200, 200))
'dispose of the graphics object
e.Dispose()
End Sub
Private Sub Form1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Resize
Me.Invalidate()
End Sub
End Class
|
|
|
|
|
may i know the way to fill the data from database to the combobox?
for datagrid the code is
datagridname.setDataBinding(dsStu, "StuTable")
then how about the combobox?
|
|
|
|
|
Create & fill a dataset object then use the combobox's DataSource and DisplayMember properties display data from the dataset.
|
|
|
|
|
|
Here is one way of binding data in combo box:
In code behind:
Dim ds As New DataSet
ds = class_Ratetype.ComboRateDisplay()
Dim dvs As New DataView(ds.Tables(0))
If dvs.Count > 0 Then
Me.ComboRoomType.DataSource = dvs
Me.ComboRoomType.DisplayMember = "Roomtype"
Me.ComboRoomType.ValueMember = "Roomtype_Id"
End If
End Sub
Class file content for this:
Public Function ComboRateDisplay() As DataSet
Dim constr As String = SqlHelper.GetConnectionString()
Dim conn As New SqlConnection(constr)
Dim cmdSQL As New SqlCommand("SP_COMBORATEDISPLAY", conn)
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim dv As New DataView
cmdSQL.CommandType = CommandType.StoredProcedure
conn.Open()
da.SelectCommand = cmdSQL
da.Fill(ds, "TBL_Roomtype")
ComboRateDisplay = ds.Copy
da.Dispose()
If (Not conn Is Nothing) Then
conn.Close()
conn.Dispose()
End If
GC.Collect()
End Function
For ur reference:
class_Ratetype ---> object for class file
ComboRoomType ----> combobox name
Roomtype ----> Display member
Roomtype_Id ----> Value member
SP_COMBORATEDISPLAY --> Stored procedure
TBL_Roomtype ----> Table name
Janani
|
|
|
|
|
I always do it like this:
comboBox1.DataSource = dtTable<br />
comboBox1.DisplayMember = "FieldToDisplay"<br />
comboBox1.ValueMember = "FieldContainingValue"
|
|
|
|
|
private sub num_KeyPress (ByVal sender......blah blah....)
If e.KeyChar < "0" or e.KeyChar > "9" then
e.handled = true
end if
end sub
can someone plz help iam only using the numbers and want to include the backspace button as well...
|
|
|
|
|
Try this:
...
If (e.KeyChar < '0' Or e.KeyChar > '9') And e.KeyChar <> '\b' Then
...
Additionally if using .NET 2.0 probably it would be better if you used PreviewKeyDown event:
Private Sub num_PreviewKeyDown(ByVal sender As Object, e As PreviewKeyDownEventArgs)
e.IsInputKey = ((e.KeyCode = Keys.Back) And (e.Modifiers = 0)) Or ((e.KeyCode >= Keys.D0 Or e.KeyCode <= D9 Or e.KeyCode >= Keys.NumPad0 Or e.KeyCode <= Keys.NumPad9) And (e.Modifiers = 0))
End Sub
This way you can handle key combinations like Alt + 0, Ctrl + Backspace, etc.
If using .NET 1.1 then use KeyDown to set a flag and check the flag value on the KeyPress event to set the Handled property.
- Xint0
|
|
|
|
|
Hi, In Vb6 if I want to write a any program that working with an operating system (example: checking the memory status, size...) I have to work with windows api. If I work with vb.net 2003, what is the technique that I use to work with windows like vb6?
|
|
|
|
|
|
I have a deadline and I need some help!
1. Is there a way in VB that you can access the computer's default programs (i.e. Browser, E-Mail etc.), and if so, how do you access it to open it.
2. I have tried everything but a Marquee progress bar does not work. It justs sits there. The code I'm using is:
<br />
Private Sub Prog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
StatProgBar.Enabled = True<br />
StatProgBar.MarqueeAnimationSpeed = 70<br />
ProgressTimer.Enabled = True<br />
Run.Enabled = True<br />
<br />
End sub<br />
<br />
<br />
Private Sub ProgressTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgressTimer.Tick<br />
StatProgBar.Value = StatProg.Value + 20<br />
If StatProgBar.Value = 100 Then<br />
StatProgBar.Value = 0<br />
End If<br />
<br />
End Sub<br />
It seems to have stopped working when I installed a new computer theme, but I don't know how this could effect it since I have seen other program's Marquee Progress Bars work fine with this theme.
Here is the theme that I have installed.
Any help would be extremely appreciated!!
|
|
|
|
|
The "default program" as you call it is tied the file extension of the file you're opening. When you double click a file, it checks the extension in the Registry, under HKEY_CLASSES_ROOT, and finds any Command values under the extensions key. That value shows the command line that's used to launch the application for that file.
To open any document or web page, all you ahve to do is start a new Process and pass it the full path to the file you want to open:
Dim proc As Process = Process.Start("C:\Documents and Settings\userid\folder\document.doc")
OR
Dim proc As Process = Process.Start("http://www.google.com")
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
UltraCoder wrote: 2. I have tried everything but a Marquee progress bar does not work. It justs sits there. The code I'm using is:
The Marquee style only works on Windows XP and above and only if you have EnableVisualStyles turned on in your application. It won't work at all on Window 2000 and below.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hey,
Is there a way to keep a form from closing? Example, if someone clicks on the close button in my program, I want the program to show a message box asking if they really want to close the program (I've got that), and then if they click no, then I want the program to stay open.
Is there a way to do this, I've seen it in other programs but I can't figure it out.
Please help! Thank you.
|
|
|
|
|
Check out the Form.Closing[^] event, complete with a sample of what you want to do.
Are you really sure you're an "Ultra" coder?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|