Solved

Copy & Past in VB 2012 texboxes

Posted on 2013-05-22
8
323 Views
Last Modified: 2013-05-22
At run time, I want the user to be able to copy from one text box and past to another textbox in a visual basic 2012 application. The textboxes really have nothing programmable going on with them. They (Textbox1 through Textbox12) are on a windows form for the purpose of being able to type info in them and printing the form out using "printform" from VB power pack. I am looking for code that will hopefully handle all 12 text boxes on this form. Thank you for any help.
0
Comment
Question by:jampost
  • 4
  • 4
8 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
They already do this out of the box...
0
 

Author Comment

by:jampost
Comment Utility
Idle Mind,

   I was thinking that too. So I need to find out why "at run time" I can not simply Ctrl-C in one Textbox and Ctrl-V to another textbox copying the contents from one to another. I'll look into prperties to see if something is turned off or on that shouldn't be.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
You must have set ShortcutsEnabled() for your TextBoxes to False.
0
 

Author Comment

by:jampost
Comment Utility
I checked ShortcutsEnabled() for your TextBoxes. they are all "true"
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Can you give more details about your app and setup?...
0
 

Author Comment

by:jampost
Comment Utility
Idle Mind,

Here is the code behind the form.



Public Class Orders

    Private m_path As String = "C:\Users\Joe\Documents\Visual Studio 2012\Projects\sa_Shipping-Receiving\My Project\Images\VL"




    Private Sub Orders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadPictures()

    End Sub

    Private Sub LoadPictures()

        Dim dir As New IO.DirectoryInfo(m_path)


        'Dim files As IO.FileInfo() = dir.GetFiles("*.jpeg")

        Dim files As IO.FileInfo() = dir.GetFiles.Where(Function(fi) fi.Extension.ToLower = ".jpeg" OrElse fi.Extension.ToLower = ".png" OrElse fi.Extension.ToLower = ".jpg" OrElse fi.Extension.ToLower = ".gif").ToArray

        Dim dra As IO.FileInfo
        For Each dra In files
            ComboBox1.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox2.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox3.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox4.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox5.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox6.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox7.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox8.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox9.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox10.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox11.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox12.Items.Add(dra.Name)
        Next  

       

    End Sub


    Private Sub Main_Click(sender As Object, e As EventArgs) Handles Main.Click
        Dim main As New Main
        main.Show()
        Me.Hide()

    End Sub

    Private Sub MnuExit_Click(sender As Object, e As EventArgs) Handles MnuExit.Click
        Me.Close()
        End
    End Sub


    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        If Not (ComboBox1.SelectedItem Is Nothing) Then
            Me.PictureBox1.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox1.SelectedItem.ToString))
        End If
        Label1.Text = ComboBox1.SelectedItem.ToString
    End Sub



    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        If Not (ComboBox2.SelectedItem Is Nothing) Then
            Me.PictureBox2.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox2.SelectedItem.ToString))
        End If
        Label2.Text = ComboBox2.SelectedItem.ToString
    End Sub

    Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
        If Not (ComboBox3.SelectedItem Is Nothing) Then
            Me.PictureBox3.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox3.SelectedItem.ToString))
        End If
        Label3.Text = ComboBox3.SelectedItem.ToString
    End Sub

    Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged
        If Not (ComboBox4.SelectedItem Is Nothing) Then
            Me.PictureBox4.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox4.SelectedItem.ToString))
        End If
        Label4.Text = ComboBox4.SelectedItem.ToString
    End Sub

    Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.SelectedIndexChanged
        If Not (ComboBox5.SelectedItem Is Nothing) Then
            Me.PictureBox5.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox5.SelectedItem.ToString))
        End If
        Label5.Text = ComboBox5.SelectedItem.ToString
    End Sub

    Private Sub ComboBox6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox6.SelectedIndexChanged
        If Not (ComboBox6.SelectedItem Is Nothing) Then
            Me.PictureBox6.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox6.SelectedItem.ToString))
        End If
        Label6.Text = ComboBox6.SelectedItem.ToString
    End Sub


    Private Sub ComboBox10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox10.SelectedIndexChanged
        If Not (ComboBox10.SelectedItem Is Nothing) Then
            Me.PictureBox10.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox10.SelectedItem.ToString))
        End If
        Label10.Text = ComboBox10.SelectedItem.ToString
    End Sub


    Private Sub ComboBox11_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox11.SelectedIndexChanged
        If Not (ComboBox11.SelectedItem Is Nothing) Then
            Me.PictureBox11.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox11.SelectedItem.ToString))
        End If
        Label11.Text = ComboBox11.SelectedItem.ToString
    End Sub

    Private Sub ComboBox12_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox12.SelectedIndexChanged
        If Not (ComboBox12.SelectedItem Is Nothing) Then
            Me.PictureBox12.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox12.SelectedItem.ToString))
        End If
        Label12.Text = ComboBox12.SelectedItem.ToString
    End Sub

   

   

    Private Sub MnuPrint_Click(sender As Object, e As EventArgs) Handles MnuPrint.Click

        'try this:
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = False
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Top = 25
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Left = 50
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Right = 0 '0.5
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0 '0.5
        '~~~~~~~~~~~~~~~~~~~~~~


        Me.PrintForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview
        Me.PrintForm1.Print()

    End Sub

 

    Private Sub ComboBox7_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
        If Not (ComboBox7.SelectedItem Is Nothing) Then
            Me.PictureBox7.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox7.SelectedItem.ToString))
        End If
        Label7.Text = ComboBox7.SelectedItem.ToString
    End Sub

    Private Sub ComboBox8_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox8.SelectedIndexChanged
        If Not (ComboBox8.SelectedItem Is Nothing) Then
            Me.PictureBox8.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox8.SelectedItem.ToString))
        End If
        Label8.Text = ComboBox8.SelectedItem.ToString
    End Sub

    Private Sub ComboBox9_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox9.SelectedIndexChanged
        If Not (ComboBox9.SelectedItem Is Nothing) Then
            Me.PictureBox9.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox9.SelectedItem.ToString))
        End If
        Label9.Text = ComboBox9.SelectedItem.ToString
    End Sub

    Private Sub MnuRefresh_Click(sender As Object, e As EventArgs) Handles MnuRefresh.Click

        Dim main As New Main
        main.Show()
        Me.Hide()
        Dim Orders As New Orders
        Orders.Show()
        main.Hide()

    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged

    End Sub

    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged

    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged

    End Sub
End Class
0
 

Author Comment

by:jampost
Comment Utility
Idle Mind,

  I attached a design view "screenPrint"
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Did you figure it out?  I didn't have time to look at your code yet...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now