LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can display number in hex format with the textbox control?

There is an array defined as:

 

unsigned char buf[20];

 

Now want to display it with the textbox control, the dispaly format is as this format: 01 1E 30 EE A0..., how to do with the control?

 

 

Thanks

 

David

 

0 Kudos
Message 1 of 2
(3,443 Views)

If you start from the number, you can format the string this way:

 

#include <ansi_c.h>
static char	msg[64];
static int		n;
static int		msk1, msk2, msk3, msk4;


msk1 = 0xFF;
msk2 = 0xFF00;
msk3 = 0xFF0000;
msk4 = 0xFF000000;
n = 12027;
sprintf (msg, "%02X %02X %02X %02X", (n & msk4) >> 24, (n & msk3) >> 16, (n & msk2) >> 8, n & msk1);

The code above can be pasted in Interactive Execution Window and executed as is. In your program you'll have to SetCtrlVal 'msg' to the textbox.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(3,435 Views)