私はこの場所とプログラミングに非常に慣れていないということから始めます.2、3日しかプログラミングしていません!! さて、私はプログラムに取り組んでいます。それは基本的にユーザーから情報を取得し、ユーザーが必要とする 28 バイトの 16 進コードを出力します。説明するのは複雑です :P とにかく、私は問題に遭遇しました。ほら、私は基本的にプログラムに「テキストボックス1の値を16進数に変換しますが、16進数が3バイトの値の場合は、その前に「0」を追加し、エンディアンを交換してください」と伝えたいのです。 16 進数への変換、3 バイトのことはすべて理解しましたが、エンディアンの部分はどこから始めればよいかさえわかりません。検索してみましたが、本当にわかりませんでした」
テキスト ボックスに表示できるように文字列に変換した 16 進数値。
ああ、あなたは何を知っていますか、私はこれを前に投稿するつもりはありませんでした.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int chInt;
string a1;
string a2;
string a3;
string a4;
string numAttire;
string chHex;
Form2 helpCH = new Form2();
int check;
public Form1()
{
InitializeComponent();
}
private void buttonCHNumberHelp_Click(object sender, EventArgs e)
{
helpCH.Show();
}
private void textBoxCHNumber_TextChanged(object sender, EventArgs e)
{
if (textBoxCHNumber.Text == "00" || textBoxCHNumber.Text == "")
{
textBoxAttireNumber.Enabled = false;
}
else
{
textBoxAttireNumber.Enabled = false;
}
if (textBoxCHNumber.Text.Length >= 3)
{
textBoxAttireNumber.Enabled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
chInt = Convert.ToInt32(textBoxCHNumber.Text);
chHex = chInt.ToString("X");
numAttire = textBoxAttireNumber.Text; //The numAttire is assigned the value currently in textBoxAttireNumber.Text;
a1 = "09"; //The variable a1 will always be "09" as that is best for the first attire.;
a2 = textBoxA2.Text; // The contents of textBoxA2 are equal to this variable;
a3 = textBoxA3.Text; // The contents of textBoxA3 are equal to this variable;
a4 = textBoxA4.Text; // The contents of textBoxA4 are equal to this variable;
check = Convert.ToInt32(textBoxAttireNumber.Text);
bool condition = check > 4; //A local boolean is set up, it's named condition and checks if the variable 'check' is bigger than 4;
if (condition) //If it is, the Output text box will display "You can only have upto 4 attires";
{
textBoxOutput.Text = "You can only have upto 4 attires";
}
else //If the statement happens to be false, ie, check IS UNDER 4, the Output text box will display the values:;
{
textBoxOutput.Text = chHex + " 00 00 00 0" +numAttire + " 00 00 00 " +a1+ " 00 00 00 FF FF FF FF " + a2 + " 00 00 00 FF FF FF FF " + a3 + " 00 00 00 FF FF FF FF " + a4 + " 00 00 00 FF FF FF FF";
int chlimit = Convert.ToInt32(textBoxCHNumber.Text);
bool chlimitbool = chlimit < 100 || chlimit > 343;
if (chlimitbool)
{
textBoxOutput.Text = "There are no ch slot numbers for values lower than 100 or higher than 343";
}
if (textBoxA1.Text == textBoxA2.Text || textBoxA1.Text == textBoxA3.Text || textBoxA1.Text == textBoxA4.Text || textBoxA2.Text == textBoxA3.Text || textBoxA2.Text == textBoxA4.Text || textBoxA3.Text == textBoxA4.Text) //If the contents of textBoxA1 are the same as the contents of textBoxA2, A3, or A4 then print out "Two attire ID slots may not share the same ID";
{
textBoxOutput.Text = "Two attire ID slots may not share the same ID";
}
if (textBoxA2.Text.Length >= 4)
{
textBoxOutput.Text = chHex + " 00 00 00 0" + numAttire + " 00 00 00 " + a1 + " 00 00 00 FF FF FF FF " + a2 + " 00 00 FF FF FF FF " + a3 + " 00 00 00 FF FF FF FF " + a4 + " 00 00 00 FF FF FF FF";
}
if (textBoxA3.Text.Length >= 4)
{
textBoxOutput.Text = chHex + " 00 00 00 0" + numAttire + " 00 00 00 " + a1 + " 00 00 00 FF FF FF FF " + a2 + " 00 00 00 FF FF FF FF " + a3 + " 00 00 FF FF FF FF " + a4 + " 00 00 00 FF FF FF FF";
}
if (textBoxA4.Text.Length >= 4)
{
textBoxOutput.Text = chHex + " 00 00 00 0" + numAttire + " 00 00 00 " + a1 + " 00 00 00 FF FF FF FF " + a2 + " 00 00 00 FF FF FF FF " + a3 + " 00 00 00 FF FF FF FF " + a4 + " 00 00 FF FF FF FF";
}
if (textBoxA3.Text == "00" && textBoxA2.Text.Length >= 4)
{
textBoxOutput.Text = chHex + " 00 00 00 0" + numAttire + " 00 00 00 " + a1 + " 00 00 00 FF FF FF FF " + a2 + " 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
}
if (textBoxA3.Text == "00" && textBoxA2.Text.Length >= 2)
{
textBoxOutput.Text = chHex + " 00 00 00 0" + numAttire + " 00 00 00 " + a1 + " 00 00 00 FF FF FF FF " + a2 + " 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
}
int fourBytetoHex = Convert.ToInt32(textBoxCHNumber.Text);
string fourByte = fourBytetoHex.ToString("X");
if (fourByte.Length == 3)
{
fourByte = "0" + fourByte;
textBoxOutput.Text = fourByte + " 00 00 0" + numAttire + " 00 00 00 " + a1 + " 00 00 00 FF FF FF FF " + a2 + " 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBoxAttireNumber.Text == "2")
{
textBoxA2.Enabled = true;
textBoxA3.Enabled = false;
textBoxA4.Enabled = false;
}
else
{
textBoxA2.Enabled = false;
}
if (textBoxAttireNumber.Text == "3")
{
textBoxA2.Enabled = true;
textBoxA3.Enabled = true;
textBoxA4.Enabled = false;
}
else
{
textBoxA3.Enabled = false;
}
if (textBoxAttireNumber.Text == "4")
{
textBoxA2.Enabled = true;
textBoxA3.Enabled = true;
textBoxA4.Enabled = true;
}
else
{
textBoxA4.Enabled = false;
}
}
private void textBoxA2_TextChanged(object sender, EventArgs e)
{
}
private void buttonWarning_Click(object sender, EventArgs e)
{
MessageBox.Show("Credits:\nCredit goes to BrienJ, Tekken57, NikeTheBike, and UndertakerWLF, people who I'm proud to call frieds, they really encouraged and helped me out when I said I wanted to start programming. Especially Tekken, who helped me out with figuring out hex conversion as well.\n\nThis is the first program I've ever made 100% using my knowledge and google, no tutorials, just my basic understanding of C#. So if you find bugs, please forgive me, I'm only a beginner :)");
}
private void textBoxA3_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
textBoxAttireNumber.Enabled = false;
textBoxA1.Enabled = false;
textBoxA2.Enabled = false;
textBoxA3.Enabled = false;
textBoxA4.Enabled = false;
}
}
}
それがコードを投稿する正しい方法でない場合は、申し訳ありません。