|
OK.
No argument here, I'll just take your word for it. Seriously.
I bowl, and my bowling couch would tell me to do this or that, and I use to argue with them about it, but now I just accept it and do it.
So I'll takes your years of wisdom on this one.
Thanks!
|
|
|
|
|
Dear experts,
I wonder if everyone could help me to create function for printing bitmap file directly via serial port.
Recently i build a small application for generate report from Sybase Anywhere. I build it in visual studio 2010 with VB.NET and use rdlc file to display report. I has a receipt printer which connect to PC by serial port.
I want to send image file such bitmap or jpg ...and if possible, i'd like to send pdf file to this printer.
So please leave your comment here. Thank you advanced for all answers.
modified 16-Jul-14 6:12am.
|
|
|
|
|
Open the COM port the printer is connected to, preferrably using the communication parameters the printer is expecting, send the data in some format that the printer expects and understands and close the port.
Given the complete lack of detail in your question, like what you're having a difficult time with, it's rather impossible to go into more detail.
|
|
|
|
|
Here is what I have so far
[code] Public Class PokerHands
Sub InputFormat() 'Function to remove space and change characters to UPPER CASE
InputDisplay.Text = InputDisplay.Text.Replace(" ", "").Replace(",","").ToUpper
End Sub
Sub FourOfaKind() 'Four of a Kind
End Sub
Sub ThreeOfaKind() 'Three of a Kind
End Sub
Sub Pair() 'A pair
End Sub
Sub Flush() 'A flush
End Sub
Sub Straight() ' A straight, if ace is low
End Sub
Sub AceStraight() 'An ace-high straight
End Sub
Private Sub InputDisplay_TextChanged(ByVal sender As Object, e As EventArgs) Handles InputDisplay.TextChanged
End Sub
Private Sub Button1_Click(ByValsender As Object, e As EventArgs) Handles Button1.Click
Dim hands(4, 13) As Integer 'Example: If (2,11) = 1 then is JD
Dim SuitsValue() As String = {"S", "D", "C", "H"}
Dim FaceValue() As String = {"2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"}
End Sub
End Class
[/code]
Hi here is what I have my code so far. I am simply stuck as how to make the program reads the user input and then display the correpsonding deck. For example: if the user input "aH, AS, 2D, 3C, 4C" the program will return ace of hearts, ace of spades, two of diamonds, three of clubs, and four of clubs? Also how can the program will recognize that the first letter (substring (0,1) is the FaceValue and the second letter substring(1,1) is the SuitsValue? I understand I will need a loop function to determine all five. I am sorry if I am asking stupid questions here but I am really stuck!!!
Thank you very much!
|
|
|
|
|
...and the question would be.....?
|
|
|
|
|
Hi, not sure if the posting didn't show all the contents, but my questions is For example: if the user input "aH, AS, 2D, 3C, 4C" the program will return ace of hearts, ace of spades, two of diamonds, three of clubs, and four of clubs? Also how can the program will recognize that the first letter (substring (0,1) is the FaceValue and the second letter substring(1,1) is the SuitsValue? I understand I will need a loop function to determine all five. I am sorry if I am asking stupid questions here but I am really stuck!!!
Thank you very much!
|
|
|
|
|
Most of this depends on how you're representing your cards, but...
First, get rid of that replace where you remove all the commas. You'll need them to split the string with.
string[] cardSpecifiers = InputDisplay.Text.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
Then it's a simple matter of iterating over the returning array of strings and parsing each for a card value and suit.
for (int i = 0; i < cardSpecifier.Length; i++)
{
cardValues[i] = cardSpecifiers[i].SubString(0, 1);
cardSuits[i] = cardSpecifiers[i].SubString(1,1);
}
|
|
|
|
|
Hi, but what I don't get is how to make the program reads the user input "InputDisplay" and then display the corresponding string from the array SuitsValue and FaceValue to the listbox "OutputDisplay". For example: if the user input "aH, AS, 2D, 3C, 4C" the program will return ace of hearts, ace of spades, two of diamonds, three of clubs, and four of clubs, the value that is stored in the arrays? Also how can the program will recognize that the first letter (substring (0,1) is the FaceValue and the second letter substring(1,1) is the SuitsValue?
|
|
|
|
|
I'm not walking you through your entire program. I've got my own 150,000 line monster to deal with full time right now.
The SubString calls will return single characters from your card specification strings. What you do with that characters is up to you. You could have a Dictionary<string, string=""> to return a full name based on the character you get back, like this:
Dim cardValueNames = New Dictionary(Of String, String)
cardValueNames.Add("a", "Ace")
cardValueNames.Add("k", "King")
cardValueNames.Add("q", "Queen")
Debug.WriteLine(cardValueNames("k"))
It sounds like you REALLY need to get a beginners book in C# and work through it.
|
|
|
|
|
Yes I am a very beginner in VB.NET and I thought this is a Visual Basic forum.....
|
|
|
|
|
My bad. It is the VB.NET forum. In either case, the book recommendation still stands.
|
|
|
|
|
I actually have 2 questions
I added an imagelist to my listview, and it always add the first image in the list to the first column.
I can eliminate the image, but it always leave a space for the image before the text, changing my aligment from left to sort of right.
Is there a way to override this?
Dim item1 As New ListViewItem(sJC(idx).FINVNO.ToString)
item1.Checked = False
item1.SubItems.Add(sJC(idx).FCUSTNO)
item1.SubItems.Add(sJC(idx).FTRANSDATE)
item1.SubItems.Add(sJC(idx).FTRANSTIME)
item1.SubItems.Add(sJC(idx).FCOMPANY)
item1.SubItems.Add(sJC(idx).FCONTACT1)
item1.SubItems.Add(sJC(idx).FEMAIL1)
item1.SubItems.Add("")
item1.SubItems.Add("")
lv_journal_icons.Items.Add(item1)
Question 2:
I used some code that extends the listview so you can add an icon or image to a subitem.
It adds the image, but I want to center the image in the column
So the code sends a message to the pump setting the cell.
I've done some c++ with listview, but I can't remember if I can send a message to the pump to center the image.
Public Sub AddIconToSubitem( _
ByVal row As Integer,
ByVal col As Integer,
ByVal icon_num As Integer)
Dim lvi As New ListViewWithIcons.LV_ITEM()
lvi.iItem = row ' Row.
lvi.iSubItem = col ' Column.
' Indicate what we're setting.
' lvi.mask = ListViewWithIcons.LVIF_IMAGE Or
' ListViewWithIcons.LVIF_TEXT
lvi.mask = ListViewWithIcons.LVIF_IMAGE
' Image index in the ImageList.
lvi.iImage = icon_num
' Send the LVM_SETITEM message.
ListViewWithIcons.SendMessage(Me.Handle, ListViewWithIcons.LVM_SETITEM, 0, lvi)
End Sub
I looked at the structure for LVITEM, and didn't see anything for alignment.
Public Structure LV_ITEM
Public mask As UInt32
Public iItem As Int32
Public iSubItem As Int32
Public state As UInt32
Public stateMask As UInt32
Public pszText As String
Public cchTextMax As Int32
Public iImage As Int32
Public lParam As IntPtr
End Structure
Queston3:
Is it default behavior for the listiew to resize the image large, I made my image 16x16 but it always displays larger.
|
|
|
|
|
Sounds more like a candidate for owner-drawing
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yeh
I looked at ownerdraw, was looking for a shortcut. Yeh right!
I finally figured out that you set the image size in image size.
The images are suppose to go in front of the text, this the view setting like files in a windows form.
I was able to center my image with a wider image, but then the first column shows the image.
So I guess for now, I'll just move the success column to the first position.
|
|
|
|
|
jkirkerx wrote: I looked at ownerdraw, was looking for a shortcut. I've often used it as such
jkirkerx wrote: So I guess for now, I'll just move the success column to the first position. Nice how there's almost always a clean and easy solution.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to Add DatagridView in ByVal ComboBox
|
|
|
|
|
|
I am attempting to create a list of lists so I can return a specific list when I reference list(index), for example. I created a custom class and am using it as the list type.
A subroutine reads through a text file (csv) one line at a time. The value in the line indicates the "section number" to which the rest of the line belongs, and all other values on that line are used to set certain properties in my custom class. (Confusing?)
Basically it reads through the lines, and if the first number is the same as the first number in the previous line, it processes the line and adds it to a list. If the number is different, it adds the list to the main list, then clears the list, and adds the current line to the new list.
And repeat until the end of the file.
Here is the code:
Dim EvalTopics As new List(of List(of customClass))
Dim sr As StreamReader = New StreamReader(BLAHBLAHBLAH)
Dim OldSec As Integer = 0, NewSec As Integer = 0 'Old and New Section Numbers
Dim seclist As New List(Of customClass) 'List to be added to EvalTopics
While Not sr.EndOfStream
Dim splits() As String = sr.Readline.Split(",")
NewSec = splits(0) 'Section # is first value
If OldSec <> NewSec Then
EvalTopics.Add(seclist)
seclist.Clear()
OldSec = NewSec
End If
Dim es As customClass = New customClass
With es
'assign the other values to various properties
End With
seclist.Add(es)
End While
EvalTopics.Add(seclist)'Add the last section
sr.Close()
After populating the lists, if I call up EvalTopics(0), I get the same as EvalTopics(3). In fact, every list I call up is the same as the LAST LIST ADDED.
Can someone point me in the right direction? At first I thought I was using lists incorrectly, so I tried an array of lists, then a list of arrays. Nothing worked.
|
|
|
|
|
Instead of
seclist.Clear()
use
seclist = New List(Of customClass)
Adding seclist to Evaltopics adds a reference, not a copy.
So it's necessary to create a new List after adding.
Cheers
|
|
|
|
|
Dang it... I KNEW that, too! I guess it is time to start drinking coffee again.
Thanks to both of you!
|
|
|
|
|
You don't get copies of Lists, or any other reference type, without explicitly making the copies. It's never done implicitly.
|
|
|
|
|
My question has a scenario like this..
Example I made a solution program in vb.net called BookProgram then the compiler for debug is 32bit or x86 and for such coding I simultaneously made also on that solution x64 compiler debug (/assume they were on bin folder)
So is it possible to put a code that design to hide the form x86 program and show x64 form program vice versa without errors even though made in one solution program?
That concrete example is based on an uninstaller program because the anycpu is based on the current bit system and programs are likely missing vice versa to 86x compiler.
|
|
|
|
|
I really hate to tell you this but I've read and re-read your post a dozen times and nothing in your post was understandable. I have no clue what you're doing nor what you're having a problem with.
|
|
|
|
|
You would need a third program that will launch either the 32 or 64-bit version as appropriate.
|
|
|
|
|
What type of program will be like to open either 32 bit and 64 bit?
|
|
|
|
|