https://barnamenevis.org/showpo...7&postcount=57
Imports System.Drawing.Printing
Private Sub GetInstalledPrinters()
For Each printerName As String In PrinterSettings.InstalledPrinters
MessageBox.Show(printerName)
Next
End Sub
https://barnamenevis.org/showpo...7&postcount=57
Imports System.Drawing.Printing
Private Sub GetInstalledPrinters()
For Each printerName As String In PrinterSettings.InstalledPrinters
MessageBox.Show(printerName)
Next
End Sub
https://barnamenevis.org/showpo...0&postcount=58
' // Create a TimeSpan representing 2.5 days.
Dim timespan1 As TimeSpan = New TimeSpan(2, 12, 0, 0)
'// Create a TimeSpan representing 4.5 days.
Dim timespan2 As TimeSpan = New TimeSpan(4, 12, 0, 0)
'// Create a TimeSpan representing 1 week.
Dim oneWeek As TimeSpan = timespan1 + timespan2
'// Create a DateTime with the current date and time.
Dim now As DateTime = DateTime.Now
'// Create a DateTime representing 1 week ago.
Dim past As DateTime = now - oneWeek
'// Create a DateTime representing 1 week in the future.
Dim future As DateTime = now + oneWeek
مثال : پیدا کردن اختلاف تعداد روزهای بین دو تاریخ :
کد:
Dim dateFrom As DateTime = DateTime.Parse("10/10/2007")
Dim dateTo As DateTime = DateTime.Parse("11/12/2007")
Dim ts As TimeSpan = dateTo - dateFrom
Dim days As Integer = ts.Days
و یا :
کد:
Dim dtFirst As DateTime = New DateTime(2007, 10, 10)
Dim dtSecond As DateTime = New DateTime(2007, 11, 12)
Dim diffResult As TimeSpan = dtSecond.Subtract(dtFirst)
https://barnamenevis.org/showpo...3&postcount=59
Imports System.IO
Dim file As FileInfo = New FileInfo("C:\test.txt")
file.Attributes = file.Attributes Or FileAttributes.ReadOnly Or FileAttributes.Hidden
https://barnamenevis.org/showpo...4&postcount=60
Imports System.IO
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
MessageBox.Show(CalculateDirectorySize(New DirectoryInfo("C:\WINDOWS\System32"), True).ToString())
End Sub
Public Function CalculateDirectorySize(ByVal directory As DirectoryInfo, ByVal includeSubdirectories As Boolean) As Long
Dim totalSize As Long = 0
'// Examine all contained files.
Dim files() As FileInfo = directory.GetFiles()
For Each file As FileInfo In files
totalSize += file.Length
Next
' // Examine all contained directories.
If includeSubdirectories Then
Dim dirs() As DirectoryInfo = directory.GetDirectories()
For Each dir As DirectoryInfo In dirs
totalSize += CalculateDirectorySize(dir, True)
Next
End If
Return totalSize
End Function
آخرین ویرایش به وسیله ghafoori : جمعه 09 فروردین 1387 در 10:15 صبح
https://barnamenevis.org/showpo...4&postcount=91
<DllImport("user32.dll")> _
Shared Function GetDC(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
End Function
<DllImport("gdi32.dll")> _
Shared Function GetPixel(ByVal hDC As IntPtr, ByVal x As Integer, ByVal y As Integer) As Integer
End Function
<DllImport("gdi32.dll")> _
Shared Function SetPixel(ByVal hDC As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal color As Integer) As Integer
End Function
Public Shared Function GetPixel(ByVal control As Control, ByVal x As Integer, ByVal y As Integer) As Color
Dim color As Color = color.Empty
If Not control Is Nothing Then
Dim hDC As IntPtr = GetDC(control.Handle)
Dim colorRef As IntPtr = GetPixel(hDC, x, y)
color = color.FromArgb((colorRef.ToInt32 & &HFF) Or (colorRef.ToInt32 & &HFF00 >> 8) Or (colorRef.ToInt32 & &HFF0000 >> 16))
ReleaseDC(control.Handle, hDC)
End If
Return color
End Function
Public Shared Sub SetPixel(ByVal control As Control, ByVal x As Integer, ByVal y As Integer, ByVal color As Color)
If Not control Is Nothing Then
Dim hDC As IntPtr = GetDC(control.Handle)
Dim argb As Integer = color.ToArgb()
Dim colorRef As Integer = ((argb & &HFF0000) >> 16) Or (argb & &HFF00) Or ((argb & &HFF) << 16)
SetPixel(hDC, x, y, colorRef)
ReleaseDC(control.Handle, hDC)
End If
End Sub