vb.net

Close form after 10 seconds

In response to http://stackoverflow.com/questions/4506033/close-form-after-10-seconds

1
2
3
4
5
6
7
8
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm2 As New Form2()
        frm2.ShowDialog()
    End Sub
 
End Class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Imports System.Timers
 
Public Class Form2
 
    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)
        Dim tmr As New System.Timers.Timer()
        tmr.Interval = 5000
        tmr.Enabled = True
        tmr.Start()
        AddHandler tmr.Elapsed, AddressOf OnTimedEvent
    End Sub
 
    Private Delegate Sub CloseFormCallback()
 
    Private Sub CloseForm()
        If InvokeRequired Then
            Dim d As New CloseFormCallback(AddressOf CloseForm)
            Invoke(d, Nothing)
        Else
            Close()
        End If
    End Sub
 
    Private Sub OnTimedEvent(ByVal sender As Object, ByVal e As ElapsedEventArgs)
        CloseForm()
    End Sub
 
End Class

VB Drag & Drop Files

From this question on Stack Overflow.

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Imports System.Windows.Forms
 
Public Class Form1
 
    Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub
 
    Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            Dim i As Integer
            MyFiles = e.Data.GetData(DataFormats.FileDrop)
            TextBox1.Text = MyFiles(i)
        End If
    End Sub
 
End Class

More Randomer - one year at a time

It's been a full year since our company's code was posted to the daily wtf at more randomer (<-- link to the more randomer post).

dilbert on random numbers.

The creator of dosomethinghere.com saw the need for cupcakes, he also has a better comment on this occasion.

wtf cupcake