Hi,
Divide the number by bytes by 1073741824 and that will give you Gigabytes.
If the above answers your question, please click Accept Answer.
Thanks.
-TP
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am working with a VB Forms application and collecting disk information. The disk size is retrieved in bytes but I want to get/convert into GB, IF POSSIBLE:
Dim DiskInfo As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_DiskDrive")
For Each queryDisk As ManagementObject In DiskInfo.Get()
RichTextBox1.AppendText(" Size (Bytes): " & queryDisk("Size") & " " & vbCrLf)
Next
Hi,
Divide the number by bytes by 1073741824 and that will give you Gigabytes.
If the above answers your question, please click Accept Answer.
Thanks.
-TP
Hi @~OSD~,
Don't know if queryDisk("Size") gets a plain numeric string, if so, you can try the following code, if not, you may have to extract its numeric part first.
RichTextBox1.AppendText(" Size (Gigabytes): " & queryDisk("Size") / 1073741824 & " " & vbCrLf)
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.