Greetings again

I have a small utility that reports which printer port has been selected.

Its returning the correct data, but in binary, LPT 1 = 0x378 = 888

Right now its reports in the message box "Printer Port 888"

I would like to change that to read "Printer Port x" as in Printer Port 1 or 2 or 3 and so on...

How would I convert the binary info to generic number?


The snippet below has the two lines of interest.

private ushort m_portBase = 0;

MessageBox.Show("Printer Port " + m_portBase);

Hi,
You could try this:

int PrinterPort = Convert.ToInt32(<The binary Value>,2);

Hope it works :)

I must be missing something.

int PrinterPort = Convert.ToInt32(m_portBase, 2);

resulted in ;

Error 1 The best overloaded method match for 'System.Convert.ToInt32(object, System.IFormatProvider)' has some invalid arguments

Error 2 Argument '2': cannot convert from 'int' to 'System.IFormatProvider'

int PrinterPort = Convert.ToInt32(m_portBase.ToString(), 2);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.