نمایش نتایج 1 تا 40 از 105

نام تاپیک: نکات، ایده ها و ترفندهای کوچک برنامه نویسی در vb.net

Hybrid View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #1
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile گرفتن و تسخیر کردن (Capture) تصویر صفحه نمایش

    کد:

    https://barnamenevis.org/showpo...8&postcount=54

     Private Function CaptureScreen() As Image

    Dim screen As Bitmap = New Bitmap(Windows.Forms.Screen.PrimaryScreen.Bounds.W idth, Windows.Forms.Screen.PrimaryScreen.Bounds.Height)
    Dim g As Graphics = Graphics.FromImage(screen)
    Using (g)
    g.CopyFromScreen(0, 0, 0, 0, screen.Size)
    End Using
    Return screen
    End Function

  2. #2
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile پخش کردن برخی اصوات و صداهای سیستمی تنها با یک خط!

    کد:
    https://barnamenevis.org/showpo...9&postcount=55

    '// Play a beep with default frequency
    '// and duration (800 and 200, respectively)
    Console.Beep()

    '/ Play a beep with frequency as 200 and duration as 300
    Console.Beep(200, 300)

    Media.SystemSounds.Asterisk.Play()

    Media.SystemSounds.Hand.Play()

    Media.SystemSounds.Exclamation.Play()

    Media.SystemSounds.Beep.Play()

    Media.SystemSounds.Question.Play()

  3. #3
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile نواختن یک فایل صوتی با فرمت Wave

    https://barnamenevis.org/showpo...5&postcount=56

    Imports System.Media

    Dim player As Media.SoundPlayer = New SoundPlayer()
    Dim path As String = "C:\windows\media\ding.wav"
    player.SoundLocation = path ' //Set the path
    player.Play() ' //play it

  4. #4
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile بدست آوردن لیست چاپگرهای نصب شده در یک سیست

    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


  5. #5
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile برخی اعمال متدوال روی تاریخ میلادی

    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)

  6. #6
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile تغییر خواص یک فایل

    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

  7. #7
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile محاسبه ی حجم کلی یک دایرکتوری

    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 صبح

  8. #8
    کاربر دائمی آواتار ghafoori
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    اصفهان-نجف اباد
    پست
    1,111

    Smile خواندن و نوشتن رنگ یک پیکسل به کمک توابع API

    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


قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •