Posts

Showing posts from April, 2020

How to paste image into picturebox from clipboard with VB.Net

Image
How to paste image into picturebox from clipboard with VB.Net If you wish to paste an image into a picturebox from clipboard for your VB.Net project, this is what to do: 1. Add a picturebox to your form. 2. Add a button and copy paste the code below.         Private Sub btnPastePic_Click(sender As Object, e As EventArgs) Handles btnPastePic.Click               'If My.Computer.Clipboard.ContainsImage Then         '    PictureBox1.Image = My.Computer.Clipboard.GetImage         'End If         Dim idata As IDataObject = Clipboard.GetDataObject()         If idata.GetDataPresent("System.Drawing.Bitmap") Then             Dim imgObject As Object = idata.GetData("System.Drawing...

How to load MS Word Document files into a Richtextbox.

Image
1. Start by saving the MS Word document as a richtext file. 2. Add the code below to a button.  3. Add a richtextbox to your project. You are good to go.  Private Sub btnBrowseRTF_Click(sender As Object, e As EventArgs) Handles btnBrowseRTF.Click Dim saveDirectory As String = Application.StartupPath & "\ProcessedRTFS" Using openFileDialog1 As OpenFileDialog = New OpenFileDialog()  openFileDialog1.Filter = "Richtext Files (*.rtf ) |*.rtf|All Files(*.*) |*.*"       If openFileDialog1.ShowDialog() = DialogResult.OK Then           If Not Directory.Exists(saveDirectory) Then  Directory.CreateDirectory(saveDirectory) End If  Dim fileName As String = Path.GetFileName(openFileDialog1.FileName)  Dim fileSavePath As String = Path.Combine(saveDirectory, fileName) File.Copy(openFileDialog1.FileName, fileSavePath, True)  'txtImgName.Text = fileName  txtPathRTF.Text = fileSa...