Cannot print a form on Zebra printer - vb.net

I'm new to this. I'm using Visual Basic from Visual Studio 2017 Community, and I have an issue printing a form.
If i use this:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
Me.PrintForm1.Print()
End Sub
on my regular printer it displays the form fine, but i needed to print the form on a label. When I change the printer to my Zebra printer, it does not display anything. Can anyone help me?

Related

How can I save the content of a rich text box even when the form closes?

This is my first post here, so please don't judge me if I write something wrong ^^
Anyways, I've recently run into an issue with richtextboxes in Visual Basic .NET and WinForms.
Let's say I have a Main form and a Log form. The log form contains a richtextbox which functions as a log. From the main form I'm writing text to the log and I also format the lines, so they have different colors (blue for information, red for error).
Unfortunately, whenever I close and reopen the log form all text that has been written to it is lost.
I've tried saving it to a text file, but that doesn't save the colors of the text.
Is there any way I can save the text and the colors of the lines even when the form closes?
Here's what the excellent suggestion from Shrotter might look like:
Public Class Form1
Private RtfPath As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim folder As String = System.IO.Path.GetDirectoryName(Application.ExecutablePath)
RtfPath = System.IO.Path.Combine(folder, "RtbData.rtf")
If System.IO.File.Exists(RtfPath) Then
RichTextBox1.LoadFile(RtfPath)
End If
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
RichTextBox1.SaveFile(RtfPath)
End Sub
End Class
Of course, you should always wrap the loading/saving of the file in a Try/Catch block in case anything goes wrong.

userform with webview-element doesn't load, program freezes

I'm new to using Visual Studio as well as Visual Basic and still struggle with getting anything to run. The only experience I have is from working with VBA in Excel.
My goal was to create a Userform which links me to frequently used webpages, without using my usually used browser.
Because I need the form to show a webplayer, which does not support internet explorer in any version, the webbrowser-windows form doesn't suit my needs.
I did however find out that there is a webview-windows form which uses the edge-rendering engine and should load the webplayer correctly.
I have a start-page as a userform with two buttons. Number one opens a second window with a webbrowser-form.
Number two is supposed to upen a window with a webview-form.
While The webbrowser-form is loaded correctly, whenever I press button number 2 the program freezes and no userform is shown.
Any idea what I could try?
Thank you in advance,
Alex
PS: Did not do much of coding, just
Public Class Form1
Private Sub btnClickThis_Click(sender As Object, e As EventArgs) Handles btnClickThis.Click
Form2.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form3.Show()
End Sub
End Class
on the first userform, to load the userform 3, which contains the webview.
Userform 3 just has this on it.
Public Class Form3
Private Sub Form3_Shown(sender As Object, e As EventArgs) Handles Me.Shown
WebViewCompatible1.Navigate("https://google.de/")
End Sub
End Class

Is there some webcam capture sample working in net framework 4? (VB.Net)

Does anybody know if there is a working sample of a webcam capture that works in net framework 4?. I tried a lot of samples:
Aforge (in 4.0 it shows me that my camera is not supported)
Emgu (shows me "System.TypeInitializationException")
webcam.dll (the picturebox stays blank)
etc.
But when I change the net framework to 3.5 all the samples works fine.
I just want to capture my webcam into a picture box but its neccesary for me make it work in net framework 4 or even 4.5
Thank you all.
This works for me..
Get EMGU using NuGet package manager.
Create a picturebox called PictureBox1
Create a Timer called Timer1
Create a button called Button1
Use this code - click on the button to start the timer which captures the webcam images. If you're ge
Imports Emgu.CV
Public Class Form1
Dim capturez As Capture = New Capture()
Dim imagez As Image
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
capturez.Start()
imagez = CType(capturez.QueryFrame.Bitmap.Clone, Bitmap)
PictureBox1.Image = imagez
capturez.Stop()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
End Class

I am trying to make a history for a text to speech program and the program is getting an error with the code I'm using

Okay let me start that here is the code that in using:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim SAPI
SAPI = CreateObject("SAPI.spvoice")
SAPI.Speak(RichTextBox1.Text)
My.Settings.History.Add(RichTextBox1.Text.ToString)
End Sub
Then I sarted the application.
But then I click Button1 I get this:
Without the code for the history it works just fine. Maybe there is a way better way to do it.
Please help.
That's because your saving your settings wrong. See example below...
Change and save Settings
My.Settings.History = RichTextBox1.Text
My.Settings.Save()

Print to a Dot-Matrix Printer directly from VB.NET

i am finishing a program i am writing and i have to create a printing to an Epson LQ-300+ Dot-Matrix. The printing has to print some text in some specific parts of the paper (Amount,name etc)
Can anyone point me to the right direction or post me an example since i was not able to find something in order to send directly the ASCII characters to the printer via LPT1.
Thank you.
IT Is going to be mainly trial and error a far as positioning goes, it is also going to depend on the font and wether or not you are using a Generic/Text Driver (if so the character spacing, line spacing and font are what ever the printer has been setup for). Back in the DOS days you could send out individual characters to the printer but printing in windows is page based meaning you will need to use the PrintDocument Class, handle the PrintPage event using the PrintPageEventArgs Graphic Property's PrintString Method to position the text where you need it to be.
Something like this:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawString("Hello World", New Font("Arial", 10), Brushes.Black, New Point(100, 100))
End Sub