|
I am developing a sample project in Visual basic 6 and MS Access 2003.
1. I wish to print Invoice in Continuous statonery (Roll Paper ) width of paper 5.5 inches
I am using printer.print Code using (x,y) co-ordinates
My problem , after printing one bill printer skips and giving lot of space between two bills. My aim printer must stop printing after completing one bill. ( no gaps required ) and user tear off that bill and continue to print next bill.
I am printing invoice in DOT MATRIX PRINTER (USB )
My code is
Dim cy As Long
Dim cx As Long
Dim cx1 As Long
Dim tmpval As Double
Set rs = New ADODB.Recordset
sql = "select * from del_head where tran=" & Trim(txtcustno.Text) & ""
rs.Open sql, CN, adOpenStatic, adLockPessimistic
If rs.RecordCount > 0 Then
cno = rs(2)
custname = rs(3)
ctown = rs(8)
Set rs3 = New ADODB.Recordset
rs3.Open "select sum(amountdue)-sum(amountrec) from receipt_d where cid = " & cno & "", CN, adOpenStatic, adLockPessimistic
custdue = rs3(0)
rs3.Close
Printer.Font = "Arial"
Printer.FontBold = True
Printer.FontSize = 12
Printer.CurrentX = 3400
Printer.CurrentY = 50
Printer.Print " XXXXXXXXXXXXXXXX "
Printer.Font = "Arial"
Printer.FontBold = False
Printer.FontSize = 10
Printer.CurrentX = 3400
Printer.CurrentY = 350
Printer.Print " XXXXXXXXXXXXXXXXXXXXX "
Printer.Font = "Arial"
Printer.FontBold = False
Printer.FontSize = 11
Printer.CurrentX = 2600
Printer.CurrentY = 650
Printer.Print " XXXXXXXXXXXXXXXXXXXX "
Printer.Font = "Arial"
Printer.FontBold = False
Printer.FontSize = 11
Printer.CurrentX = 3300
Printer.CurrentY = 950
Printer.Print " XXXXXXXXXXXXXXXXXXXX "
Printer.Font = "Arial"
Printer.FontBold = False
Printer.FontSize = 9
Printer.CurrentX = 6400
Printer.CurrentY = 50
Printer.Print " XXXXXXXXXXXXXXXX "
Printer.Font = "Arial"
Printer.FontBold = False
Printer.FontSize = 9
Printer.CurrentX = 6400
Printer.CurrentY = 200
Printer.Print " : XXXXXXXXXXXXXXXX "
Printer.Font = "Arial"
Printer.FontBold = False
Printer.FontSize = 9
Printer.CurrentX = 6350
Printer.CurrentY = 550
Printer.Print " XXXXXXXXXXXXXXXX"
Printer.CurrentX = 1000
Printer.CurrentY = 1150
Printer.FontSize = 9
Printer.Print " Bill No : " & rs(1)
Printer.CurrentX = 3600
Printer.CurrentY = 1150
Printer.FontSize = 8
Printer.Print " INVOICE "
Printer.CurrentX = 6150
Printer.CurrentY = 1150
Printer.FontSize = 9
Printer.Print " Date : " & rs(4)
Printer.Line (1000, 1400)-(7800, 1400) '-h line
'Printer.Line (20, 10)-(20, 18800) 's1
'Printer.Line (11520, 10)-(11520, 18800) 's2
'Printer.Line (10, 18800)-(11500, 18800) 'bl
Printer.Font = "DCI + Tml + Ismail"
Printer.CurrentX = 100
Printer.CurrentY = 1550
Printer.Print " tpguk; fp tpiy bjhif"
Printer.Line (1000, 1800)-(7800, 1800) '-h line
cy = 2000
cx = 6500
Set rs1 = New ADODB.Recordset
sql = "select * from del_det where transno=" & Trim(txtcustno.Text) & ""
rs1.Open sql, CN, adOpenStatic, adLockPessimistic
Do While Not rs1.EOF
Printer.Font = "DCI + Tml + Ismail"
Printer.CurrentX = 1100
Printer.CurrentY = cy
Printer.Print rs1(3)
Printer.Font = "Arial"
Printer.FontSize = 10
Printer.CurrentX = 3500
Printer.CurrentY = cy
Printer.FontSize = 9
Printer.Print rs1(4)
Printer.CurrentX = 4700 - TextWidth(rs1(5))
Printer.CurrentY = cy
Printer.Print Format(rs1(5), "00.00")
Printer.CurrentX = cx - TextWidth(rs1(6))
Printer.CurrentY = cy
Printer.Print Format(rs1(6), "00.00")
'Format$(123,"@@@@@@")
rs1.MoveNext
cy = cy + 250
Loop
Printer.Line (6000, cy)-(7800, cy) '-h line
Printer.Font = "DCI + Tml + Ismail"
Printer.CurrentX = 4500
Printer.CurrentY = cy + 100
Printer.FontSize = 10
Printer.Print " bkhj;jk; "
Printer.Font = "Arial"
Printer.CurrentX = cx - TextWidth(rs(7))
Printer.CurrentY = cy + 100
Printer.FontSize = 10
Printer.Print Format(rs(7), "00.00")
cy = cy + 300
Printer.Line (6000, cy)-(7800, cy) '-h line
Printer.Font = "DCI + Tml + Ismail"
Printer.CurrentX = 4500
Printer.CurrentY = cy + 300
Printer.FontSize = 10
Printer.Print " bkhj;j ghf;fp "
Printer.Font = "Arial"
Printer.CurrentX = cx - TextWidth(custdue)
Printer.CurrentY = cy + 300
Printer.FontSize = 10
Printer.Print Format(custdue, "00.00")
cy = cy + 600
Printer.Line (6000, cy)-(7800, cy) '-h line
Printer.EndDoc
End If
|
|
|
|
|
imagetvr wrote: I am developing a sample project in Visual basic 6 and MS Access 2003.
Why are you using VB6? It's been dead for quite a long time now.
In the .NET world, there is the PosPrinter class in the Microsoft POS for .NET library that will do what you want. No, you can't use it in your VB6 code.
The code you've written will not work because you're "printing" to a paper size. This size is required by the Printer object and cannot be infinitely long or of an undetermined size before you start printing. You have to "print" directly to the printer itself without using the Printer object. That also means you do not get to specify fonts and sizes like you have. You have to specify these things, if possible at all, by using the control characters and commands specific to the printer. See the printers documentation on how to do this.
|
|
|
|
|
I made a program, that contains two forms, one is the controls form and the other is the screen which the actions appear on it.
I use screen splitting and HDMI cable.
I make the screen 'Duplicate' option
I connect the PC with a TV, I share Form2(screen) to the tv and Form1(controls) on my PC's screen.
HERE IS MY PROBLEM!!!!
all sounds from both screens get out to the tv
but I want to split sounds or decide which sounds go to which screen either TV or PC
I have buttons that produce different types of sounds.
|
|
|
|
|
Interesting concept ... I've never come across a screen that plays sounds
|
|
|
|
|
so do you think there's a solution for it?
|
|
|
|
|
Have a look at this link[^] it might help.
Failing that, Google is your friend
|
|
|
|
|
Thank you for your effort.
and I found a program that do what I exactly needed.
it's CheVolume, which determines each application to playback on either device.
|
|
|
|
|
I'm new to await, and have always had trouble understanding it. Like I make an await function, and then VS 2013 Tells me to make the calling function await, and just keeps moving up the chain.
So this time I did some research on it.
http://stackoverflow.com/questions/14888984/start-async-task-without-using-await-in-called-method[^]
In the link above, there's 2 examples, and I found the 2nd one easier to understand.
But I'm wondering if I should use example 1 instead. What do you think?
Here's what I have. i'd like to be able to check on the status, and have it update the form with emails sent and status, if it's still running and complete, so I can change the form color back. Not sure if I'm on the right track, and wanted to check before I write more code. But so far so good, it works.
Public Enum _smtpEngine_Status
STOPPED = 1
START_PENDING = 2
STOP_PENDING = 3
RUNNING = 4
CONTINUE_PENDING = 5
PAUSE_PENDING = 6
PAUSED = 7
COMPLETE = 8
EMPTY = 9
End Enum
Public Class smtp_send_engine
'<a href="http://stackoverflow.com/questions/14888984/start-async-task-without-using-await-in-called-method">http://stackoverflow.com/questions/14888984/start-async-task-without-using-await-in-called-method</a>
Public Shared engineTask As Task
Public Shared Function engineStart( _
ByVal pSend As frmSend,
ByVal pJobID As Integer,
ByVal pPageIndex As Integer,
ByVal pPageSize As Integer) As _smtpEngine_Status
Dim pValue As _smtpEngine_Status = _smtpEngine_Status.START_PENDING
'No need for sub to be async but can be async if needed for other reasons (see below)
'but that doesn't stop the execution in the CallingSub
'Get the task started... it's not going to wait for the task to be done just sets the task variable
engineTask = engineRun( _
pSend,
pJobID,
pPageIndex,
pPageSize
)
Return pValue
End Function
Public Shared Async Sub engineStatus()
'Must be async so you can await the result
Await engineTask
'Do stuff that requires task to be done
End Sub
Private Shared Async Function engineRun( _
ByVal pSend As frmSend,
ByVal pJobID As Integer,
ByVal pPageIndex As Integer,
ByVal pPageSize As Integer) As Task(Of _smtpEngine_Status)
'No need for this function to be async since the function has no await
Dim pValue As _smtpEngine_Status = _smtpEngine_Status.START_PENDING
Dim responseCount As New crm.ws_sendEngine_subscribersCount_response
Dim dwXCode As Integer = request_sendEngine_Count.get_Subscriber_Count(responseCount)
If Not (responseCount.count > 0) Then
Return _smtpEngine_Status.EMPTY
Exit Function
Else
Await Task.Delay(30000)
pValue = _smtpEngine_Status.COMPLETE
End If
Return pValue
End Function
End Class
|
|
|
|
|
The problem with asking for an opinion is that you will probably get conflicting responses. You also have no means of determining whose response is "best" for you (lots of reputation points is no indicator of expertise in any one particular subject!)
Try them both out and see which is more appropriate to your own circumstances ... you've said you are new to the subject, so how better to learn and retain than to write that code?
One general comment that I've seen to be true more times than I care to admit - if it's simple to understand now then it will be simple to understand when you have to come back to the code days, months, years later ... this is a Good Thing.
Alternatively, ask the opinions of the posters on that other forum where you got the examples.
|
|
|
|
|
I had a really hard time getting the 2nd one to work, but it works good. So I guess I'll stick with it. And I have a better understanding of await now as well.
|
|
|
|
|
|
This was a head scratcher for me, first time I have used await. Before I was using new Thread.
Not sure what the difference is, guess I should do a search on it. But It seems to work fine so far, I still need to plugin the SMTP Message Sender, which is new Thread. Maybe I should update it to await.
I'm not sure what to do with the EngineStatus, I'd like to get the status of EngineRunAsync.
The calling function that returns from the dialog result OK or Send, and raises an event to update the form to RED color so the user knows it's running.
So this time VS 2013 did not bug me to use Await, and just the one call was fine.
Dim m_status As _smtpEngine_Status = Await smtp_send_engine.engineStart(Me, gJobID, gJobIndex, gJobSize)
RaiseEvent SendEngineStatus(m_status, "COMPLETED", gJobID)
Update_SendEngine_Status("Send Engine has completed successfully", _smtpEngine_Status.COMPLETE, gJobID)
My Class that runs in await.
Public Enum _smtpEngine_Status
STOPPED = 1
START_PENDING = 2
STOP_PENDING = 3
RUNNING = 4
CONTINUE_PENDING = 5
PAUSE_PENDING = 6
PAUSED = 7
COMPLETE = 8
EMPTY = 9
End Enum
Public Class smtp_send_engine
Public Shared engineTask As Task(Of _smtpEngine_Status)
Public Shared Async Function engineStart( _
ByVal pSend As frmSend,
ByVal pJobID As Integer,
ByVal pPageIndex As Integer,
ByVal pPageSize As Integer) As Task(Of _smtpEngine_Status)
engineTask = engineRunAsync(pSend, pJobID, pPageIndex, pPageSize)
Dim pValue As String = Await engineTask
pValue = _smtpEngine_Status.COMPLETE
Return pValue
End Function
Public Shared Async Sub engineStatus()
Await engineTask
End Sub
Private Shared Async Function engineRunAsync( _
ByVal pSend As frmSend,
ByVal pJobID As Integer,
ByVal pPageIndex As Integer,
ByVal pPageSize As Integer) As Task(Of _smtpEngine_Status)
For idx As Integer = 0 To m_pages - 1
For jdx As Integer = 0 To 25 - 1
Await Task.Delay(2500)
m_sent += 1
m_remaining -= 1
Application.DoEvents()
Next
Next
pValue = _smtpEngine_Status.COMPLETE
return pValue
End Sub
|
|
|
|
|
I am using LINQ to group by however after group By I need to create a new table with data...
I am using Dataview to get all data
Dim vDependent As DataView = myDataTable.DefaultView
vDependent.RowFilter = "EEGRP ='" & item.EEGRP & "' AND EESSN ='" & item.EESSN & "'"
Is there is a better way to do this?
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .EEGRP = r.Field(Of String)("EEGRP"), Key .EESSN = r.Field(Of String)("EESSN"), _ Key .DEDENF = r.Field(Of String)("DEDENF"), Key .DEDENM = r.Field(Of String)("DEDENM"), _
Key .DEDREL = r.Field(Of String)("DEDREL")},
Function(key, rows) New With
{
Key .EEGRP = key.EEGRP,
Key .EESSN = key.EESSN,
Key .DEDENF = key.DEDENF,
Key .DEDENM = key.DEDENM,
Key .DEDREL = key.DEDREL,
.Dates = rows.Select(Function(r) DateFromStringParts( _
r.Field(Of String)("DEIBCY"), _
r.Field(Of String)("DEIBYR"), _
r.Field(Of String)("DEIBMT"), _
r.Field(Of String)("DEIBDY"))).OrderByDescending(Function(d) d).Take(3).ToList()}
)
Dim result As New DataTable
result = myDataTable.Clone()
For Each item In data
Dim vDependent As DataView = myDataTable.DefaultView
vDependent.RowFilter = "EEGRP ='" & item.EEGRP & "' AND EESSN ='" & item.EESSN & "'"
Dim newRow As DataRow = result.NewRow()
newRow("EEGRP") = vDependent(0)("EEGRP")...
|
|
|
|
|
I downloaded this source from code Project because I needed an HTML Editor.
I was just wondering if you gius think I should build this as a seperate project, and add it to my project?
So I would build it, and then add it to my toolbox, and drop the control onto my form.
A Windows Forms based text editor with HTML output[^]
|
|
|
|
|
It says, in the article:
To embed it into your own app, simply reference the EXE as if it were a DLL from your app in Visual Studio.
It should show up in the Toolbox Window in Visual Studio.
Check the source code for examples of how to access it from your code.
|
|
|
|
|
I should of read the whole article, how stupid of me.
|
|
|
|
|
It often helps, yes.... on the same principle, I remember my math teacher at school used to drum it into our heads over and over: "Read the question at least three times before even attempting to answer it. And if you get stuck, read it again." Nowadays, this is encapsulated in the acronym "RTFM". The answer is, as they say, (usually) out there.
|
|
|
|
|
I need to implement that rule again.
Well, at least I translated the project to VB and got it to work, plus upgraded it to 4.51. Just need to fix the little errors and fine tune it for my needs. Pretty neat how it works.
|
|
|
|
|
I am reposting my problem hopefully a bit more specific for you guys!
The program I am writing uses various labels which retrieves data from Microsoft Access.
I use the following code to print a specific label:
e.Graphics.DrawString(lblMethod.Text, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 10, 420)
Although this works fine and prints but this particular label text has a lots of text and therefore does not wordwrap as such.
How can I get this label to wordwrap automatically?
|
|
|
|
|
You're not printing a label. You're printing text. Also, your code leaks resources since you're not disposing the Font object you created.
There's plenty of examples on then web. All you have to do is Google for "vb.net print string to printer with word wrap[^]".
|
|
|
|
|
HI,
i need to write a procedure to send a file by ftp or tcp from a Datalogic mobile device to a PC in the same LAN.
The mobile device has a SO win CE 5.0 and is connected to the switch by wireless connection.
I tryed using VB 2005 to create a connection but nothing seems working.
Does anybody have an idea about how to send files from win ce to a pc using VB?
Thanks.
|
|
|
|
|
|
I am trying to use linq...however running into the issue...
how to I combine 3 fileds to Date?
.Dates = rows.Select(Function(r) r.Field(Of DateTime?)("DEIBMT") & "/" & ("DEIBDY") & "/" & ("DEIBCY") & ("DEIBYR"))
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .EEGRP = r.Field(Of String)("EEGRP"), Key .EESSN = r.Field(Of String)("EESSN")},
Function(key, rows) New With
{
Key .EEGRP = key.EEGRP,
Key .EESSN = key.EESSN,
.Dates = rows.Select(Function(r) _
r.Field(Of String)("DEIBMT")) _
.OrderByDescending(Function(d) d).Take(3).ToList()}
)
|
|
|
|
|
It depends what type your columns are. Assuming integers, something like this should work:
.Dates = rows.Select(Function(r) New DateTime( _
(100 * r.Field(Of Integer)("DEIBCY")) + r.Field(Of Integer)("DEIBYR"), _
r.Field(Of Integer)("DEIBMT"), _
r.Field(Of Integer)("DEIBDY")))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
All columns string... could you show me how I should do this with strings?
|
|
|
|
|