private void button1_Click(object sender, EventArgs e) { try { int command = 0, data = 0; try { command = int.Parse(tbCommand.Text, System.Globalization.CultureInfo.CurrentCulture); } catch (Exception) { } try { data = int.Parse(tbData.Text, System.Globalization.CultureInfo.CurrentCulture); } catch (Exception) { } LastResult = null; rbBytes.Enabled = rbHex.Enabled = rbString.Enabled = rbBits.Enabled = false; DirectIOData ret = poscommon.DirectIO(command, data, tbObject.Text); //MessageBox.Show(ret.ToString()); //tbResult.Text = ret.ToString(); if (ret == null) { tbResultData.Text = "<null>"; tbResultObject.Text = "<null>"; } else { tbResultData.Text = ret.Data.ToString(CultureInfo.InvariantCulture); if (ret.Object == null) { tbResultObject.Text = "<null>"; } else if (ret.Object is byte[]) { rbBytes.Enabled = rbHex.Enabled = rbString.Enabled = rbBits.Enabled = true; LastResult = ret.Object as byte[]; UpdateLastResult(); } else { tbResultObject.Text = ret.Object.ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }