Merge pull request #18 from thoblerone/master

Fixes Issue #17
This commit is contained in:
Graham Ross
2020-06-15 10:34:00 -04:00
committed by GitHub
2 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -74,7 +74,7 @@
// txtSize
//
this.txtSize.Location = new System.Drawing.Point(211, 16);
this.txtSize.MaxLength = 3;
this.txtSize.MaxLength = 5;
this.txtSize.Name = "txtSize";
this.txtSize.Size = new System.Drawing.Size(40, 20);
this.txtSize.TabIndex = 34;
+10 -3
View File
@@ -56,12 +56,13 @@ namespace Modbus.Common
ushort rVal = 64;
try
{
if (txtSize.Text.IndexOf("0x", 0, txtSize.Text.Length) == 0)
if (txtSize.Text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
{
string str = txtSize.Text.Replace("0x", "");
rVal = Convert.ToUInt16(str, 16);
}
rVal = Convert.ToUInt16(txtSize.Text);
else
rVal = Convert.ToUInt16(txtSize.Text);
}
catch (Exception)
{
@@ -71,7 +72,13 @@ namespace Modbus.Common
}
set
{
txtSize.Text = Convert.ToString(value);
if (txtSize.Text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
{
// obey hex input
txtSize.Text = "0x"+Convert.ToString(value, 16);
}
else
txtSize.Text = Convert.ToString(value);
}
}