Click here to Skip to main content
15,891,812 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionCheck selected item of combobox Pin
Manfr3d29-Apr-07 23:28
Manfr3d29-Apr-07 23:28 
AnswerRe: Check selected item of combobox Pin
Colin Angus Mackay30-Apr-07 0:00
Colin Angus Mackay30-Apr-07 0:00 
Questionhelp in convertiting the vb code in vb.net Pin
Suhail Shahab29-Apr-07 21:55
Suhail Shahab29-Apr-07 21:55 
AnswerRe: help in convertiting the vb code in vb.net Pin
Christian Graus30-Apr-07 0:22
protectorChristian Graus30-Apr-07 0:22 
Questionhow to detect storage device name in smart device Pin
laurensia inge29-Apr-07 21:08
laurensia inge29-Apr-07 21:08 
Questionremaining free space on HD Pin
charchabil0329-Apr-07 20:56
charchabil0329-Apr-07 20:56 
AnswerRe: remaining free space on HD [modified] Pin
Sonia Gupta29-Apr-07 21:52
Sonia Gupta29-Apr-07 21:52 
AnswerRe: remaining free space on HD Pin
johnjsm30-Apr-07 7:25
johnjsm30-Apr-07 7:25 
Try this. In this example you will need one button and 3 textboxes.Hope this helps

Declareations


 Inherits System.Windows.Forms.Form<br />
    Private Declare Function GetDiskFreeSpaceEx _<br />
    Lib "kernel32" _<br />
    Alias "GetDiskFreeSpaceExA" _<br />
    (ByVal lpDirectoryName As String, _<br />
    ByRef lpFreeBytesAvailableToCaller As Long, _<br />
    ByRef lpTotalNumberOfBytes As Long, _<br />
    ByRef lpTotalNumberOfFreeBytes As Long) As Long<br />
<br />
<br />
<br />
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
        TextBox1.Text = GetFreeSpace("C:\")<br />
        TextBox2.Text = GetTotalSpace("C:\")<br />
        GetPercentageFree()<br />
        If TextBox3.Text < 36 Then<br />
            MsgBox("You are running out of space")<br />
        End If<br />
    End Sub<br />
    Public Function GetFreeSpace(ByVal Drive As String) As Long<br />
        'returns free space in MB, formatted to two decimal places<br />
        'e.g., msgbox("Free Space on C: "& GetFreeSpace("C:\") & "MB")<br />
<br />
        Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long<br />
<br />
        Dim iAns As Long<br />
<br />
        iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _<br />
             lBytesTotal, lFreeBytes)<br />
        If ians > 0 Then<br />
<br />
            Return BytesToMegabytes(lFreeBytes)<br />
        Else<br />
            Throw New Exception("Invalid or unreadable drive")<br />
        End If<br />
<br />
<br />
    End Function<br />
<br />
<br />
    Public Function GetTotalSpace(ByVal Drive As String) As String<br />
        'returns total space in MB, formatted to two decimal places<br />
        'e.g., msgbox("Free Space on C: "& GetTotalSpace("C:\") & "MB")<br />
<br />
        Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long<br />
<br />
        Dim iAns As Long<br />
<br />
        iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _<br />
             lBytesTotal, lFreeBytes)<br />
        If iAns > 0 Then<br />
<br />
            Return BytesToMegabytes(lBytesTotal)<br />
        Else<br />
            Throw New Exception("Invalid or unreadable drive")<br />
        End If<br />
    End Function<br />
<br />
    Private Function BytesToMegabytes(ByVal Bytes As Long) _<br />
    As Long<br />
<br />
<br />
        Dim dblAns As Double<br />
        dblAns = (Bytes / 1024) / 1024<br />
        BytesToMegabytes = Format(dblAns, "###,###,##0.00")<br />
<br />
    End Function<br />
    Public Function GetPercentageFree()<br />
        Dim free As Integer<br />
        Dim total As Integer<br />
        Dim percent As Integer<br />
        free = GetFreeSpace("C:\")<br />
        total = GetTotalSpace("C:\")<br />
<br />
        percent = (free / total) * 100<br />
        TextBox3.Text = percent<br />
    End Function

QuestionHow to populate listbox with it's filepath Pin
x86phre3x29-Apr-07 20:37
x86phre3x29-Apr-07 20:37 
AnswerRe: How to populate listbox with it's filepath Pin
Christian Graus29-Apr-07 20:59
protectorChristian Graus29-Apr-07 20:59 
AnswerRe: How to populate listbox with it's filepath Pin
A*****29-Apr-07 21:13
A*****29-Apr-07 21:13 
GeneralRe: How to populate listbox with it's filepath Pin
x86phre3x30-Apr-07 19:26
x86phre3x30-Apr-07 19:26 
Questionopen a new form from previous one Pin
dadhich29-Apr-07 20:33
dadhich29-Apr-07 20:33 
AnswerRe: open a new form from previous one [modified] Pin
A*****29-Apr-07 20:41
A*****29-Apr-07 20:41 
GeneralRe: open a new form from previous one Pin
Christian Graus29-Apr-07 20:59
protectorChristian Graus29-Apr-07 20:59 
GeneralRe: open a new form from previous one Pin
A*****29-Apr-07 21:16
A*****29-Apr-07 21:16 
GeneralRe: open a new form from previous one Pin
Dave Kreskowiak30-Apr-07 8:13
mveDave Kreskowiak30-Apr-07 8:13 
QuestionHow to open only one instance of an application? Pin
just3ala229-Apr-07 20:18
just3ala229-Apr-07 20:18 
AnswerRe: How to open only one instance of an application? Pin
just3ala229-Apr-07 20:51
just3ala229-Apr-07 20:51 
AnswerRe: How to open only one instance of an application? Pin
Steven J Jowett30-Apr-07 0:42
Steven J Jowett30-Apr-07 0:42 
GeneralRe: How to open only one instance of an application? Pin
just3ala230-Apr-07 3:41
just3ala230-Apr-07 3:41 
QuestionProblem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 20:09
Jats_4ru29-Apr-07 20:09 
AnswerRe: Problem while data insertion in Access - Plz need help Pin
Christian Graus29-Apr-07 21:00
protectorChristian Graus29-Apr-07 21:00 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 21:08
Jats_4ru29-Apr-07 21:08 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Colin Angus Mackay30-Apr-07 5:24
Colin Angus Mackay30-Apr-07 5:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.