not showing the design
-
12 Maret 2012 15:53
Hi,
im writing tic tac toe and i want a form to receive from another form so i used this code but now the design doesnt show up what should i do?
private void Form1_Load(object sender, EventArgs e) { udps = new UdpClient(); UdpClient udpss = new UdpClient(10001); IPEndPoint ipep = null; while ( button5.Text!="Player") { byte[] bindata = udpss.Receive(ref ipep); string data = Encoding.ASCII.GetString(bindata); byte[] binhavij = udpss.Receive(ref ipep); string havij = Encoding.ASCII.GetString(binhavij); if (data == "O" && havij == ",3") Console.WriteLine("O"); } }
Semua Balasan
-
13 Maret 2012 16:30
So you receive two separate packets; and then you match for a string in each. Is that what you intended?
Or did you intend to receive one packet and look for the two string in it?
http://www.alanjmcf.me.uk/ Please follow-up in the newsgroup. If I help, please vote and/or mark the question answered. Available for contract programming.
-
13 Maret 2012 17:18
i receive two packets but thats not the problem now,the problem is that when i debug the project it dowsnt open any window showing my form...
my code is so long so ill just put 1 button of it here that might help...its not the shortest way i couldve written it.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.Net.Sockets; namespace dana1 { public partial class Form1 : Form { int a = 0; UdpClient udps; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { udps = new UdpClient(); UdpClient udpss = new UdpClient(10001); IPEndPoint ipep = null; while ( button5.Text!="Player") { byte[] bindata = udpss.Receive(ref ipep); string data = Encoding.ASCII.GetString(bindata); byte[] binhavij = udpss.Receive(ref ipep); string havij = Encoding.ASCII.GetString(binhavij); if (data == "O" && havij == ",3") Console.WriteLine("O"); } } private void button1_Click(object sender, EventArgs e) { if (button5.Text != "Player") { if (button1.Text != "X" && button1.Text != "O") { if (a % 2 == 0) { button1.Text = "X"; a++; byte[] data = Encoding.ASCII.GetBytes(button1.Text); udps.Send(data, data.Length, "127.0.0.1", 10002); byte[] havij = Encoding.ASCII.GetBytes(",1"); udps.Send(havij, havij.Length, "127.0.0.1", 10002); } else { button1.Text = "O"; a++; byte[] data = Encoding.ASCII.GetBytes(button1.Text); udps.Send(data, data.Length, "127.0.0.1", 10002); byte[] havij = Encoding.ASCII.GetBytes(",1"); udps.Send(havij, havij.Length, "127.0.0.1", 10002); } if (button1.Text == "O" && button4.Text == "O" && button7.Text == "O") { button1.Text = ""; button2.Text = ""; button3.Text = ""; button4.Text = "O "; button5.Text = "Player"; button6.Text = "Wins!"; button7.Text = ""; button8.Text = ""; button9.Text = ""; } } }