Click here to Skip to main content
14,766,799 members
Home » Discussions » Visual Basic
   

Visual Basic

 
QuestionCheck selected item of combobox Pin
Manfr3d30-Apr-07 0:28
MemberManfr3d30-Apr-07 0:28 
AnswerRe: Check selected item of combobox Pin
Colin Angus Mackay30-Apr-07 1:00
MemberColin Angus Mackay30-Apr-07 1:00 
Questionhelp in convertiting the vb code in vb.net Pin
Suhail Shahab29-Apr-07 22:55
MemberSuhail Shahab29-Apr-07 22:55 
AnswerRe: help in convertiting the vb code in vb.net Pin
Christian Graus30-Apr-07 1:22
protectorChristian Graus30-Apr-07 1:22 
Questionhow to detect storage device name in smart device Pin
laurensia inge29-Apr-07 22:08
Memberlaurensia inge29-Apr-07 22:08 
Questionremaining free space on HD Pin
charchabil0329-Apr-07 21:56
Membercharchabil0329-Apr-07 21:56 
AnswerRe: remaining free space on HD [modified] Pin
Sonia Gupta29-Apr-07 22:52
MemberSonia Gupta29-Apr-07 22:52 
AnswerRe: remaining free space on HD Pin
johnjsm30-Apr-07 8:25
Memberjohnjsm30-Apr-07 8: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 21:37
Memberx86phre3x29-Apr-07 21:37 
AnswerRe: How to populate listbox with it's filepath Pin
Christian Graus29-Apr-07 21:59
protectorChristian Graus29-Apr-07 21:59 
AnswerRe: How to populate listbox with it's filepath Pin
A*****29-Apr-07 22:13
MemberA*****29-Apr-07 22:13 
GeneralRe: How to populate listbox with it's filepath Pin
x86phre3x30-Apr-07 20:26
Memberx86phre3x30-Apr-07 20:26 
Questionopen a new form from previous one Pin
dadhich29-Apr-07 21:33
Memberdadhich29-Apr-07 21:33 
AnswerRe: open a new form from previous one [modified] Pin
A*****29-Apr-07 21:41
MemberA*****29-Apr-07 21:41 
GeneralRe: open a new form from previous one Pin
Christian Graus29-Apr-07 21:59
protectorChristian Graus29-Apr-07 21:59 
GeneralRe: open a new form from previous one Pin
A*****29-Apr-07 22:16
MemberA*****29-Apr-07 22:16 
GeneralRe: open a new form from previous one Pin
Dave Kreskowiak30-Apr-07 9:13
mveDave Kreskowiak30-Apr-07 9:13 
QuestionHow to open only one instance of an application? Pin
just3ala229-Apr-07 21:18
Memberjust3ala229-Apr-07 21:18 
AnswerRe: How to open only one instance of an application? Pin
just3ala229-Apr-07 21:51
Memberjust3ala229-Apr-07 21:51 
AnswerRe: How to open only one instance of an application? Pin
Steven J Jowett30-Apr-07 1:42
MemberSteven J Jowett30-Apr-07 1:42 
GeneralRe: How to open only one instance of an application? Pin
just3ala230-Apr-07 4:41
Memberjust3ala230-Apr-07 4:41 
QuestionProblem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 21:09
MemberJats_4ru29-Apr-07 21:09 
AnswerRe: Problem while data insertion in Access - Plz need help Pin
Christian Graus29-Apr-07 22:00
protectorChristian Graus29-Apr-07 22:00 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 22:08
MemberJats_4ru29-Apr-07 22:08 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Colin Angus Mackay30-Apr-07 6:24
MemberColin Angus Mackay30-Apr-07 6: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.