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

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

Hybrid View

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

    Smile جابجا کردن فرم با کلیک بر روی هر قسمت از آن - بدون استفاده از توابع API

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


    کد:


    Private dragging As Boolean
    Private pointClicked As Point

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    If (e.Button = MouseButtons.Left) Then

    '// Turn drag mode on and store the point clicked.
    dragging = True
    pointClicked = New Point(e.X, e.Y)
    Else

    dragging = False
    End If
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    If dragging Then

    Dim pointMoveTo As Point
    '// Find the current mouse position in screen coordinates.
    pointMoveTo = Me.PointToScreen(New Point(e.X, e.Y))
    '// Compensate for the position the control was clicked.
    pointMoveTo.Offset(-pointClicked.X, -pointClicked.Y)
    '// Move the form.
    Me.Location = pointMoveTo
    End If
    End Sub

    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
    dragging = False
    End Sub

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

    Smile انتقال مقادیر خاصیت Text دو تکست باکس از طریق Drag & Drop

    کد:

    ابتدا خاصیت allow drop را true کنید

    Private Sub TextBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
    TextBox1.SelectAll()
    TextBox1.DoDragDrop(TextBox1.Text, DragDropEffects.Copy)
    End Sub

    Private Sub TextBox2_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
    If (e.Data.GetDataPresent(DataFormats.Text)) Then
    e.Effect = DragDropEffects.Copy
    Else
    e.Effect = DragDropEffects.None
    End If
    End Sub

    Private Sub TextBox2_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
    TextBox2.Text = CType(e.Data.GetData(DataFormats.Text), String)
    End Sub

  3. #3
    کاربر دائمی آواتار 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

  4. #4
    کاربر دائمی آواتار 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()

  5. #5
    کاربر دائمی آواتار 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

  6. #6
    کاربر دائمی آواتار 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


  7. #7
    کاربر دائمی آواتار 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)

  8. #8
    کاربر دائمی آواتار 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

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

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