Click here to Skip to main content
15,897,334 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Copy / Paste Multiple Textboxes Pin
Eddy Vluggen23-Jan-14 7:50
professionalEddy Vluggen23-Jan-14 7:50 
10kbps wrote:
I want to get somehow to user can copy all at once ID and be able to paste serial all at once not to fill one box by another, any help about it maybe some code snippet or something?
Here's something;
VB
Imports System.Windows.Forms

Module Module1

    Dim tb1 As TextBox
    Dim tb2 As TextBox
    Dim tb3 As TextBox

    Sub Main()
        Using f As New Form()
            tb1 = New TextBox With {.Dock = DockStyle.Left, .MaxLength = 3}
            tb2 = New TextBox With {.Dock = DockStyle.Left, .MaxLength = 5}
            tb3 = New TextBox With {.Dock = DockStyle.Left, .MaxLength = 3}
            f.Controls.AddRange(New Control() {tb3, tb2, tb1})

            AddHandler tb1.KeyDown, AddressOf KeyDown
            tb1.Focus()

            f.ShowDialog()
        End Using
    End Sub

    Public Sub KeyDown(sender As Object, e As KeyEventArgs)
        If e.KeyCode = Keys.V And e.Control = True Then
            ' did the enduser attempt a paste-operation?
            e.Handled = True

            DivideThisStringOverSomeTextBoxes(Clipboard.GetText)
        End If
    End Sub

    Public Sub DivideThisStringOverSomeTextBoxes(someString As String)
        ' our imaginary serial is 11 chars over 3 tb's; 123-45678-901
        ' first remove any - from the string
        Dim tempString As String = someString.Replace("-", "")
        tb1.Text = tempString.Substring(startIndex:=0, length:=3)
        tb2.Text = tempString.Substring(startIndex:=3, length:=5)
        tb3.Text = tempString.Substring(startIndex:=8, length:=3)
    End Sub

End Module
Mind you, this will explode if you post a string of ten characters; you'd still have to add in that check, before the substring is done Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

Questionconvert visual basic 6.0 to visual basic 2010 Pin
kikyamelia18-Jan-14 18:48
kikyamelia18-Jan-14 18:48 
AnswerRe: convert visual basic 6.0 to visual basic 2010 Pin
Peter Leow18-Jan-14 19:11
professionalPeter Leow18-Jan-14 19:11 
GeneralRe: convert visual basic 6.0 to visual basic 2010 Pin
kikyamelia18-Jan-14 20:21
kikyamelia18-Jan-14 20:21 
GeneralRe: convert visual basic 6.0 to visual basic 2010 Pin
Peter Leow18-Jan-14 20:36
professionalPeter Leow18-Jan-14 20:36 
AnswerRe: convert visual basic 6.0 to visual basic 2010 Pin
Eldar Zeynalov24-Jan-14 19:03
Eldar Zeynalov24-Jan-14 19:03 
AnswerRe: convert visual basic 6.0 to visual basic 2010 Pin
TheComputerMan31-Jan-14 5:07
TheComputerMan31-Jan-14 5:07 
QuestionSub reports Pin
Tsunamipudip17-Jan-14 2:10
Tsunamipudip17-Jan-14 2:10 
QuestionDelegates & Pointers Pin
Synth_Boy16-Jan-14 2:14
Synth_Boy16-Jan-14 2:14 
AnswerRe: Delegates & Pointers Pin
Paulo Zemek16-Jan-14 3:17
Paulo Zemek16-Jan-14 3:17 
GeneralRe: Delegates & Pointers Pin
Synth_Boy16-Jan-14 4:20
Synth_Boy16-Jan-14 4:20 
AnswerRe: Delegates & Pointers Pin
Dave Kreskowiak16-Jan-14 3:31
mveDave Kreskowiak16-Jan-14 3:31 
GeneralRe: Delegates & Pointers Pin
Synth_Boy16-Jan-14 4:24
Synth_Boy16-Jan-14 4:24 
GeneralRe: Delegates & Pointers Pin
Ron Beyer16-Jan-14 4:50
professionalRon Beyer16-Jan-14 4:50 
GeneralRe: Delegates & Pointers Pin
Synth_Boy16-Jan-14 5:15
Synth_Boy16-Jan-14 5:15 
GeneralRe: Delegates & Pointers Pin
Ron Beyer16-Jan-14 5:17
professionalRon Beyer16-Jan-14 5:17 
GeneralRe: Delegates & Pointers Pin
Synth_Boy16-Jan-14 6:03
Synth_Boy16-Jan-14 6:03 
AnswerRe: Delegates & Pointers Pin
Synth_Boy30-Jan-14 22:02
Synth_Boy30-Jan-14 22:02 
QuestionVb script Pin
Member 1052588115-Jan-14 4:25
Member 1052588115-Jan-14 4:25 
AnswerRe: Vb script Pin
Dave Kreskowiak15-Jan-14 4:38
mveDave Kreskowiak15-Jan-14 4:38 
AnswerRe: Vb script Pin
Ron Beyer15-Jan-14 5:00
professionalRon Beyer15-Jan-14 5:00 
Questionexe file Pin
Member 1052323315-Jan-14 2:23
Member 1052323315-Jan-14 2:23 
AnswerRe: exe file Pin
thatraja15-Jan-14 2:31
professionalthatraja15-Jan-14 2:31 
Questionvb 6.0 birthday reminder form code Pin
akcworld14-Jan-14 18:00
akcworld14-Jan-14 18:00 
AnswerRe: vb 6.0 birthday reminder form code Pin
Dave Kreskowiak14-Jan-14 18:13
mveDave Kreskowiak14-Jan-14 18:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.