Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
AnswerRe: Getting position of IBean of RichTextBox Pin
Adobe200725-Apr-07 8:14
Adobe200725-Apr-07 8:14 
AnswerRe: Getting position of IBean of RichTextBox Pin
Adobe200725-Apr-07 8:44
Adobe200725-Apr-07 8:44 
QuestionNullReferenceException in WaitForWaitHandle Pin
jayart25-Apr-07 6:21
jayart25-Apr-07 6:21 
QuestionReverse Find Pin
LCI25-Apr-07 5:13
LCI25-Apr-07 5:13 
AnswerRe: Reverse Find Pin
led mike25-Apr-07 5:39
led mike25-Apr-07 5:39 
AnswerRe: Reverse Find Pin
Guffa25-Apr-07 5:39
Guffa25-Apr-07 5:39 
AnswerRe: Reverse Find Pin
kubben25-Apr-07 9:04
kubben25-Apr-07 9:04 
GeneralNew Error: A namespace does not directly contain members such as fields or methods Pin
cole2325-Apr-07 5:03
cole2325-Apr-07 5:03 
hi.. i'm writing a prog to send and write data to a clock via a serial port. i hv some errors on the code.. can someone look at my code and help me solve the prob? this is the errors i got...

Error1: A namespace does not directly contain members such as fields or methods



namespace Proj
{
public partial class Form1 : Form
{

private string[] tx_data = new string[14];
private string[] rx_data = new string[10];
public int i;



public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void label16_Click(object sender, EventArgs e)
{

}

private void label18_Click(object sender, EventArgs e)
{

}






private void button3_Click(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

}

private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

}

private void txtTxmID1_TextChanged(object sender, EventArgs e)
{

}

private void txtTxmID5_TextChanged(object sender, EventArgs e)
{

}

private void lblRx2_TextChanged(object sender, EventArgs e)
{

}

private void lblRx5_TextChanged(object sender, EventArgs e)
{

}

private void cmdRead_Click(object sender, EventArgs e)
{
//For i = 1 To 6
// lblRx(i).Caption = rx_data(i + 1)
//Next i

string OutString = null;
string Instring = null;
int y = 0;
open_port;
//If the port is opened...
if (Comm1.PortOpen)
{
//tx_data(0) = "R"
//tx_data(1) = "I"
//tx_data(2) = "D"
//For i = 0 To 2
// Comm1.Output = tx_data(i)
//Next i
OutString = "RID";
Comm1.Output = OutString;
}
}
public void writeID(string SysID, string SchID, string DeptID, string BlkID, string LevelID, string ClkID)
{
string OutString = null;
OutString = "";
tx_data[0] = "R";
tx_data[1] = "P";
tx_data[2] = "g";
tx_data[3] = cvtHexToDec(SysID);
tx_data[4] = cvtHexToDec(SchID);
tx_data[5] = cvtHexToDec(DeptID);
tx_data[6] = cvtHexToDec(BlkID);
tx_data[7] = cvtHexToDec(LevelID);
tx_data[8] = cvtHexToDec(ClkID);
System.DateTime mytime = DateTime.MinValue;
int HOU = 0;
int MIN = 0;
int SEC = 0;
mytime = Time; //obtain current system time
HOU = mytime.Hour; //obtain current system hour
MIN = mytime.Minute; //obtain current system minute
SEC = mytime.Second; //obtain current system seconds

tx_data[9] = cvtHexToDec(System.Convert.ToString(HOU));
tx_data[10] = cvtHexToDec(System.Convert.ToString(MIN));
tx_data[11] = cvtHexToDec(System.Convert.ToString(SEC));
tx_data[12] = cvtHexToDec("00");

for (i = 0; i <= 12; i++)
{
OutString = OutString + tx_data[i];
}
open_port;
//If the port is opened...
if (Comm1.PortOpen)
{
Comm1.Output = OutString;
Comm1.PortOpen = false;
}
}

public object cvtHexDec(string txtID)
{
string firstnum = null;
string secnum = null;
int f = 0;
int s = 0;
if (txtID.Length == 2)
{
firstnum = txtID.Substring(0, 1).ToUpper();
secnum = txtID.Substring(1, 1).ToUpper();
}
else
{
firstnum = "0";
secnum = txtID.Substring(0, 1).ToUpper();
}
for (i = 65; i <= 70; i++) // check for A - F (Hex format)
{
if (firstnum == (char)(i))
{
f = (i - 55) * 16;
break;
}
}
for (i = 48; i <= 57; i++) // check for 0 - 9 (Hex format)
{
if (firstnum == (char)(i))
{
f = (i - 48) * 16;
break;
}
}

for (i = 65; i <= 70; i++) // check for A - F (Hex format)
{
if (secnum == (char)(i))
{
s = i - 55;
break;
}
}
for (i = 48; i <= 57; i++) // check for 0 - 9 (Hex format)
{
if (secnum == (char)(i))
{
s = i - 48;
break;
}
}

f = f + s; //add the total of fisrtnum & secnum dec
cvtHexDec = (char)(f); //convert back to char
}

public object cvtHexToDec(string txtID)
{
string firstnum = null;
string secnum = null;
byte f = 0;
byte s = 0;
if (txtID.Length == 2)
{
firstnum = txtID.Substring(0, 1).ToUpper();
secnum = txtID.Substring(1, 1).ToUpper();
}
else
{
firstnum = "0";
secnum = txtID.Substring(0, 1).ToUpper();
}
if (System.Convert.ToInt32(firstnum[0]) >= 65)
{
f = System.Convert.ToInt32(firstnum[0]) - 55;
}
else
{
f = System.Convert.ToInt32(firstnum[0]) - 48;
}
f = f * 16;

if (System.Convert.ToInt32(secnum[0]) >= 65)
{
s = System.Convert.ToInt32(secnum[0]) - 55;
}
else
{
s = System.Convert.ToInt32(secnum[0]) - 48;
}
f = f + s; //add the total of fisrtnum & secnum dec
return (char)(f); //convert back to char
}

private void cmdWrite_Click(object sender, EventArgs e);

}
writeID(txtTxmID0.Text.ToUpper(),txtTxmID1.Text.ToUpper(),txtTxmID2.Text.ToUpper(), txtTxmID3.Text.ToUpper(), txtTxmID4.Text.ToUpper(),txtTxmID5.Text.ToUpper());
}
GeneralRe: Error2: Identifier expected Pin
CPallini25-Apr-07 6:09
mveCPallini25-Apr-07 6:09 
GeneralRe: Error2: Identifier expected Pin
Jimmanuel25-Apr-07 8:07
Jimmanuel25-Apr-07 8:07 
Questionget xml data Pin
arkiboys25-Apr-07 4:59
arkiboys25-Apr-07 4:59 
AnswerRe: get xml data Pin
kubben25-Apr-07 5:35
kubben25-Apr-07 5:35 
GeneralRe: get xml data Pin
arkiboys25-Apr-07 5:37
arkiboys25-Apr-07 5:37 
GeneralRe: get xml data Pin
kubben25-Apr-07 5:48
kubben25-Apr-07 5:48 
QuestionBlocking Multiple Application accessing the same file Pin
girijaa25-Apr-07 4:33
professionalgirijaa25-Apr-07 4:33 
AnswerRe: Blocking Multiple Application accessing the same file Pin
Colin Angus Mackay25-Apr-07 4:47
Colin Angus Mackay25-Apr-07 4:47 
AnswerRe: Blocking Multiple Application accessing the same file Pin
Tim Paaschen25-Apr-07 19:50
Tim Paaschen25-Apr-07 19:50 
QuestionContextMenu and ListView problem? Pin
Khoramdin25-Apr-07 4:25
Khoramdin25-Apr-07 4:25 
AnswerRe: ContextMenu and ListView problem? Pin
led mike25-Apr-07 4:33
led mike25-Apr-07 4:33 
QuestionSorting DataGrid when datasource is a DataSet Pin
Chris_Green25-Apr-07 3:35
Chris_Green25-Apr-07 3:35 
AnswerRe: Sorting DataGrid when datasource is a DataSet Pin
kubben25-Apr-07 5:38
kubben25-Apr-07 5:38 
GeneralRe: Sorting DataGrid when datasource is a DataSet Pin
Chris_Green25-Apr-07 5:42
Chris_Green25-Apr-07 5:42 
QuestionCreate a Better looking panel? Pin
Carlos Adriano Portes25-Apr-07 3:16
professionalCarlos Adriano Portes25-Apr-07 3:16 
AnswerRe: Create a Better looking panel? Pin
Patrick Etc.25-Apr-07 4:16
Patrick Etc.25-Apr-07 4:16 
QuestionApplication error question Pin
LCI25-Apr-07 2:53
LCI25-Apr-07 2:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.