Anda di halaman 1dari 4

Dim SelectQry = "SELECT (Username)as [User Name],(user_Password) as [Password]

FROM users "


Dim SampleSource As New DataSet
Dim TableView As DataView
Try
Dim SampleCommand As New OleDbCommand()
Dim SampleDataAdapter = New OleDbDataAdapter()
SampleCommand.CommandText = SelectQry
SampleCommand.Connection = Connection
SampleDataAdapter.SelectCommand = SampleCommand
SampleDataAdapter.Fill(SampleSource)
TableView = SampleSource.Tables(0).DefaultView
Catch ex As Exception
Throw ex
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
Return TableView

product code generation

Public Shared Function GetUniqueKey(ByVal maxSize As Integer) As String


Dim chars As Char() = New Char(61) {}
chars = "123456789".ToCharArray()
Dim data As Byte() = New Byte(0) {}
Dim crypto As New RNGCryptoServiceProvider()
crypto.GetNonZeroBytes(data)
data = New Byte(maxSize - 1) {}
crypto.GetNonZeroBytes(data)
Dim result As New StringBuilder(maxSize)
For Each b As Byte In data
result.Append(chars(b Mod (chars.Length)))
Next
Return result.ToString()
End Function

Sub auto()
txtProductCode.Text = "P-" & GetUniqueKey(4)
End Sub

======================================enter key using code


Private Sub tbSecurity_KeyPress(sender As System.Object, e As System.EventArgs)
Handles tbSecurity.KeyPress
Dim tmp As System.Windows.Forms.KeyPressEventArgs = e
If tmp.KeyChar = ChrW(Keys.Enter) Then
MessageBox.Show("Enter key")
Else
MessageBox.Show(tmp.KeyChar)
End If

End Sub
Private Sub SomeTextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
SomeTextBox.KeyPress

If Asc(e.KeyChar) = 13 Then
MessageBox.Show("Enter pressed!")
e.Handled = True
End If

End Sub

Private Sub txtFiltro_PreviewKeyDown(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.PreviewKeyDownEventArgs) Handles txtFiltro.PreviewKeyDown
Select Case e.KeyCode
Case Keys.Enter
e.IsInputKey = True
End Select
End Sub

and then you would handle the event keydown on the textbox. One of the answer was
on the right track but missed setting the e.IsInputKey.

Private Sub txtFiltro_KeyDown(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles txtFiltro.KeyDown
If e.KeyCode = Keys.Enter Then
e.handled = True
Textbox1.Focus()
End If
End Sub

Use the KeyDown event of your TextBox:

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

If e.KeyCode = Keys.Enter Then

'do something here...

End If

End Sub
Add the following line of code to your Page_Load event

Page.RegisterHiddenField("__EVENTTARGET", "YourButtonName")

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

PictureBox1.Image = Image.FromFile("d:\testImage.jpg")
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

End Sub

End Class

NOTE: If you want the MDI parent to auto-size the child form you can code
like this.
form.MdiParent = Me
form.Dock = DockStyle.Fill
form.Show()

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
IsMdiContainer = True
End Sub

Private Sub MenuItem1ToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles MenuItem1ToolStripMenuItem.Click
Dim frm2 As New Form2
frm2.Show()
frm2.MdiParent = Me
End Sub

Private Sub MenuItem2ToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles MenuItem2ToolStripMenuItem.Click
Dim frm3 As New Form3
frm3.Show()
frm3.MdiParent = Me
End Sub

End Class
https://www.youtube.com/watch?v=LfHSZ7vLwyU&feature=youtu.be create
delee

Anda mungkin juga menyukai