|
Yeah,you have any further details about controlling the receipt printer tools or solution? I feel its so complicated now here. How can I really control the printer to print data save inside the txt file and how to control the printer cut the paper?
Hope someone give me a hand here.
Regards
Drexler
|
|
|
|
|
Having a problem with getting this code right. I cant get the names to show up. Don't know how to do listbox, loop, or input box.
This was the problem: create an application that alows a teacher to enter 3 test scores each for three students. The application should calculate each student's average test score an assign a letter grade based on the following grade scale.
[/b]Average Test Score [b]Letter Grade
90 or better A
80 through 89 B
70 through 79 C
60 through 69 D
Below 60 F
The application should prompt the user for each student's name and three test scores. This is an example of how the application's form should appear after all data is entered. Example:
Jennie James: Average: 90.66666 Grade: A
Sammy Smith: Average: 73 Grade: C
Julie Williams: Average: 84.66666 Grade: B
|
|
|
|
|
You are going to have to give us the code you have written and what errors you are getting.
We are not going to do your homework for you.
|
|
|
|
|
I don't know how to do the loop, or listbox, or input box. I just need some help getting started.
This is the code:
Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
'Declare varialbes
Dim Score1 As String
Dim Score2 As Double
Dim Score3 As Double
Dim Data As String
Dim Grade As String
'Get input
Score1 = InputBox("Enter Student Name, Student Name")
InputBox("Enter Student Grade, Student Grade")
InputBox("Enter Student Grade Letter, Grade Letter")
lblData.Text = Score1
'Calculate Average
Data = (Score1 Or Score2 Or Score3)
'Display Average
lblData.Text = FormatNumber(Data, 2)
'If score is high, compliment the student
If Data > 95 Then
MessageBox.Show("Congradulations! Great Job!", "Message")
Else
MessageBox.Show("Keep Trying", "Message")
End If
If Data >= 90 Then
Grade = "A"
ElseIf Data >= 80 Then
Grade = "B"
ElseIf Data >= 70 Then
Grade = "C"
ElseIf Data >= 60 Then
Grade = "D"
Else
Grade = "F"
End If
End Sub
|
|
|
|
|
muscle wrote: Data = (Score1 Or Score2 Or Score3)
That's not going to do it. Do you know mathematically how to calculate an average ? Giving Score2 and Score3 values would also help.
If you're going to use a loop, then I would assume you're going to set up an array to hold the values, or, keep a running total.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading
Imports System.IO
Imports System.ComponentModel
Public Class Form1
Public Delegate Sub UpdateTextBox(ByVal Text As String)
Dim tagid As String
Dim tcpClient As New System.Net.Sockets.TcpClient
Dim networkStream As NetworkStream
Dim buffer(1024) As Byte
Dim Synchronizer As ISynchronizeInvoke
Dim MyUpdateTextBox As UpdateTextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim buf() As Byte
buf = Encoding.ASCII.GetBytes(TextBox1.Text.Trim())
Try
networkStream.Write(buf, 0, buf.Length)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
TextBox1.Clear()
TextBox1.Focus()
End Sub
Private Sub MyReadCallback(ByVal ar As IAsyncResult)
Dim buffer() As Byte
Dim Read As Integer
Dim Data As String
Try
buffer = ar.AsyncState
Read = networkStream.EndRead(ar)
Data = Encoding.ASCII.GetString(buffer, 0, Read)
networkStream.BeginRead(buffer, 0, buffer.Length, New AsyncCallback(AddressOf MyReadCallback), buffer)
Catch ex As Exception
Data = ex.ToString()
End Try
If (Synchronizer.InvokeRequired = False) Then
TextBox2.Text = TextBox2.Text & Data
Else
Synchronizer.Invoke(MyUpdateTextBox, New Object() {Data})
End If
End Sub
Private Sub UpdateTextBoxDelegate(ByVal Text As String)
TextBox2.Text = TextBox2.Text & Text
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sendBytes("!quit!".Length + 1) As Byte
Try
sendBytes = Encoding.ASCII.GetBytes("!quit!")
networkStream.Write(sendBytes, 0, sendBytes.Length)
networkStream.Close()
tcpClient.Close()
Application.Exit()
Catch ex As Exception
tcpClient.Close()
Me.Close()
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim ipAddress As String
Dim port As String
Try
MyUpdateTextBox = New UpdateTextBox(AddressOf UpdateTextBoxDelegate)
ipAddress = TextBox3.Text
port = TextBox4.Text
tcpClient.Connect(ipAddress, port)
MessageBox.Show("connected")
networkStream.BeginRead(buffer, 0, buffer.Length, New AsyncCallback(AddressOf MyReadCallback), buffer)
Synchronizer = Me.TextBox2
Button1.Enabled = True
Button4.Enabled = True
Catch ex As Exception
MsgBox("Cannot connect to the specified address or port")
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox2.Clear()
End Sub
End Class
_________________________________________________________________________
this is sample of my client application using tcpclient,
then the prob here how can i make a server application by manipulate the code above, anyone have idea what should i do now? please..
|
|
|
|
|
Try asking a specific question, not posting a ton of code like this and hoping someone will rewrite it for you.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi people, I'm having this issue and I don't know how to start with it. The client is using a commercial application and he usually must print two copies of every document, keeping one as backup. He wants to replace the backup copy with a PDF file instead of the physical copy. Also, sometimes he sends, for example, 40 documents to print at once, and he would like to have those 40 documents in a same PDF file. This is what I though: Create a "virtual printer" to receive the printing request. Then, this printer should do two things: convert the document to a pdf file and also send it to the real printer. Then, merge all the PDF files created together to a single file. But I really have no idea of how to do it at all... How can I create something that the Windows XP will recognize as a printer?
Please help me with this, or at least give me a direction to follow!
Thanks!!
|
|
|
|
|
You can get free or commercial printer drivers that generate PDFs.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I know that, but I want something that does the following:
- Generate a PDF (or print into a PDF file)
- Print it (for real, to a printer previously designed by the user)
- Merge all the PDFs created (the whole batch that has been sent to the printer) into one file (named by the user)
The client is already using a PDF printer, but he must rename each file and he can't merge them together.
Is it clear enough NOW?
|
|
|
|
|
SentencedToLive wrote: Is it clear enough NOW?
Gee - given the attitude, maybe I shouldn't bother replying.
You have two options, brainiac.
1 - buy a PDF library and write some code to generate PDFs ( which still means writing code to stream all the jobs into one )
2 - write printing code that runs all your reports into one, and run that one print job through the PDF printer you can get for free
Is that clear enough now ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hey, I never meant to be rude...
As I said before, the problem is that this is not my app, but a commercial one. Imagine this is MS Word. The app would need to look like a printer to windows in order to do this, right? Is that possible?
|
|
|
|
|
You want to control printing in a third party app ? You could do it with Word, as it provides a .NET interface to allow you to control it. Were that not the case, I guess you'd have to write your own printer driver that collects documents before being told to finalise into one PDF. Or, you could buy a PDF library that lets you load and merge PDFs.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You can't write a standard printer driver using .NET (nor VB6) as it has to be an old-style dll.
You can, however, set printers to have teh setting "Keep printed documents after printing" and archive the spool files off each night - this is how many companies do what yours seem to be looking for. There are many apps around that can view spool files should that be required at a later date.
|
|
|
|
|
I want to create cv but i dont know how i can start. I use sql db and vb.net. Cv include person information (personality info, education, different language,etc.)
Thanks
|
|
|
|
|
Is this homework, or a work assignment ? If the former, talk to your teacher. If the latter, talk to your boss.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dear all
I have got an academic project where, in the part 1 of the project, I need to read an usb device and get its PID, VID and other info. I need to do it in VB.Net.
Is there any procedure while working from Visual studio SDK, after surfing thru net for sometime I have learnt that there is one 'HID Class' which is supported only in Microsoft DDK .
Please help me regarding this matter.
|
|
|
|
|
Ok, I'm sure someone out here has a fix for this....
I have a project at work (in VB 2005) which has a couple mutually exclusive .dll's which are loaded at runtime. Occasionally, especialy when I switch which one gets compiled and included in the Debug, the symbols don't get loaded properly for the .dll, which means I am unable to debug anything inside it. Usually, I'm able to get it working without too much effort (though I'm never entirely sure what actually fixes it), but this time, nothing I do seems to fix it.
I have tried deleting the file from both the folder the .dll compiles in, and the the folder the scripting copies the folder to for runtime. I have tried Cleaniing the Solution. I have tried doing all the above and rebooting. I have checked the Debug settings: Debug is enabled, Optimizations are not. I have tried loading the .pdb manually, but VB says it doesn't match. And I have tried any number of other supposed fixes that haven't worked.
Does anybody else have any ideas on how to get the symbols to load so I can debug? This is getting very irritating, and so far has cost me a day of work for just this one incident.
Please help!
|
|
|
|
|
OK, so after trying pretty much everything under the sun, I gave up and decided to just put in a MsgBox where I wanted it to break. Not as useful as an actual Breakpoint, but at least I could check one of the things I was wanting to check.
So, I compiled and ran.
My MsgBox didn't appear. The application didn't get to the MsgBox line................
....................
....................
....................
...because it stopped at my Breakpoint.
Don't you just love Microsoft?
|
|
|
|
|
I amhaving problems with my db connection. In a form connected to the db through a table adaptor if i restore using CancelEdit, and then add new again the dataset retains the next sequential autonumber. i.e addnew id is 79, restore, addnew id is 80, when no 79 was actually created in the access db. I have tried restore etc to no avail. How can i reset the dataset to match the current autonumbers in the db. Thanks
|
|
|
|
|
First - why do you care what happened to ID 79 as long as the record was not saved.
Second - learn about ID fields, they should not have a use other than identifying the record. If your system is failing because there is no 79 you are using 79 for other than id. STOP.
This is a classic mistake all new programmers encounter.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The reason i care :P is that when you try to delete the newly created record it uses the id as its Id into the back end (Db), there is no match so i get an error every time. so 79 in the dataset is actually say 77 in the Access db (Autonumber). In an ideal world this wouldn't happen however.. BTW yes i am new (trying to self teach) but am aware that an id is just that, a record placer.
|
|
|
|
|
I am trying to set a picturebox's image property to my database. The database column is called "Picture" and it is in binary format.
I am using this code for the textboxes:
textbox1.databindings.add("Text", BindingSource1, "FName")
Now this part works great but when I apply the same theory to the picturebox control, it will not bind.
Here is the picturebox control code for binding the binary data in the MS Access database:
picturebox.databindings.add("Image", BindingSource1, "Picture")
Could someone assist?
thanks,
jason
I'd rather have a bottle in front of me than a frontal lobotomy.
|
|
|
|
|
Hi Jason,
Please know that Images are stored in database as BLOB short for Binary Large OBject, a collection of binary data stored as a single entity in a database management systems (DBMS). BLOBs are used primarily to hold multimedia objects such as images, videos, and sound, though they can also be used to store programs or even fragments of code. Not all DBMSs support BLOBs.
Therefore, to read or write an image we need to use array of Byte. Below is a code snippet to read an image from a database and to show it on a picture box.
----------------------------------------------------------------------------------------------------
BEGIN CODE
' Construct a SQL string and a connection object
Dim sql As String = "SELECT UserPhoto FROM Users"
Dim conn As OleDbConnection = New OleDbConnection
conn.ConnectionString = connectionString
' Open connection
If conn.State <> ConnectionState.Open Then
conn.Open()
End If
Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
Dim fs As FileStream
Dim bw As BinaryWriter
Dim bufferSize As Integer = 300000
Dim outbyte(300000 - 1) As Byte
Dim retval As Long
Dim startIndex As Long = 0
Dim pub_id As String = ""
Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)
' Read first record
reader.Read()
fs = New FileStream(savedImageName, FileMode.OpenOrCreate, FileAccess.Write)
bw = New BinaryWriter(fs)
startIndex = 0
retval = reader.GetBytes(0, 0, outbyte, 0, bufferSize)
bw.Write(outbyte)
bw.Flush()
' Close the output file.
bw.Close()
fs.Close()
reader.Close()
' Display image
curImage = Image.FromFile(savedImageName)
PictureBox1.Image = curImage
PictureBox1.Invalidate()
' Clean up connection
If conn.State = ConnectionState.Open Then
conn.Close()
' Dispose connection
conn.Dispose()
End If
End Sub
END CODE
----------------------------------------------------------------------------------------------------
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi John-
Thanks for replying back. I have some questions about your code.
My connection setup is all done on the GUI side (using Dataset, bindingsource, and bindingnavigator). What I am doing is loading my data on startup of my app...my data loads fine (including the picbox) and the app is working great. What I was trying to do is create a checkbox on the form that, when checked, would parse the data out to display only the information in my new dataset, connectionstring, and query. And when unchecked, it would go back to its original state.
I got all that to work as well except for in the picbox. What I am doing is clearing all the databinding and then manually re-binding the data in the code. Everything updates when I do this except for the picbox.
Now to my question
I am using the code you provided and things needed modified but I am getting an error on "curImage". Can you elaborate on this part? I will provide your code again...you can then see the changes that were necessary to make (but may not be knowing that my connection setup is fine).
'Construct a SQL string and a connection object
Dim sql As String = "SELECT PK, FName, LName, CO, Street, City, State, Zip, Zip2, Email, SentDate, Sent, ReceivedDate, Received, Notes, Location, AddySource, Success, RTS, Fee, Preprint, Profession, TypedLetter, Picture, International, SentEmail FROM(ADDRESSES)WHERE(Success = 'Success')ORDER BY LName"
Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\jasons\Desktop\Autographs\bin\Autographs.mdb"
' Open connection
If conn.State <> ConnectionState.Open Then
conn.Open()
End If
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql, conn)
Dim fs As FileStream
Dim bw As BinaryWriter
Dim bufferSize As Integer = 300000
Dim outbyte(300000 - 1) As Byte
Dim retval As Long
Dim startIndex As Long = 0
Dim pub_id As String = ""
Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)
' Read first record
reader.Read()
fs = New FileStream("Picture", FileMode.OpenOrCreate, FileAccess.Write)
bw = New BinaryWriter(fs)
startIndex = 0
retval = reader.GetBytes(0, 0, outbyte, 0, bufferSize)
bw.Write(outbyte)
bw.Flush()
' Close the output file.
bw.Close()
fs.Close()
reader.Close()
' Display image
curImage = Image.FromFile("Picture")
picImage.Image = curImage
picImage.Invalidate()
Thanks,
jason
I'd rather have a bottle in front of me than a frontal lobotomy.
|
|
|
|
|