3000310032003300 3400350036003700 3800390061006200 6300640065006600 0123456789abcdef 6700680069006A00 6B006C006D006E00 6F00700071007200 7300740075007600 ghijklmnopqrstuv 7700780079007A00 10FF11FF12FF13FF 14FF15FF16FF17FF 18FF19FF41004200 wxyz0123456789AB 4300440045004600 4700480049004A00 4B004C004D004E00 4F00500051005200 CDEFGHIJKLMNOPQR 5300540055005600 5700580059005A00 21FF22FF23FF24FF 25FF26FF27FF3900 STUVWXYZABCDEFG9 3800370036003500 3400330032003100 3000 876543210 |
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
| ファイル名 | 説明 |
|---|---|
| BinDump.cs | 16進数表示 |
private string str =
"0123456789" +
"abcdefghijklmnopqrstuvwxyz" +
"0123456789" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"ABCDEFG"+
"9876543210";
|
// textBox1
textBox1 = new TextBox();
textBox1.Parent = this;
textBox1.Font = new System.Drawing.Font("MS ゴシック", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
textBox1.Location = new System.Drawing.Point(10, 10);
textBox1.Name = "textBox1";
textBox1.Size = new System.Drawing.Size(640, 320);
this.textBox1.Multiline = true;
|
Load += new System.EventHandler(MyForm_Load);
Paint += new PaintEventHandler(MyHandler);
|
// Load で呼ばれるメソッド
private void MyForm_Load(object sender, System.EventArgs e)
{ int i,j,k;
byte al,ah;
wstr = "";
for(i=0; i<str.Length; i+=16)
{ j = str.Length-i;
if (j > 16) j = 16;
for(k=0; k<j; k++)
{ ah= (byte)(str[i+k]>>8);
al= (byte)str[i+k];
wstr+= al.ToString("X2");
wstr+= ah.ToString("X2");
if (k % 4 == 3) wstr += " ";
}
wstr += "\r\n";
wstr+= str.Substring(i,j);
wstr+= "\r\n";
}
}
|
private void MyHandler(object sender, PaintEventArgs e)
{
textBox1.Text = wstr;
}
|
/*******************************************/
/*★ 16進数と文字で表示する 前田 稔 ★*/
/*******************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
{
private TextBox textBox1;
private string str =
"0123456789" +
"abcdefghijklmnopqrstuvwxyz" +
"0123456789" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"ABCDEFG"+
"9876543210";
private string wstr;
public MyForm()
{
Width = 700;
Height = 400;
// textBox1
textBox1 = new TextBox();
textBox1.Parent = this;
textBox1.Font = new System.Drawing.Font("MS ゴシック", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
textBox1.Location = new System.Drawing.Point(10, 10);
textBox1.Name = "textBox1";
textBox1.Size = new System.Drawing.Size(640, 320);
this.textBox1.Multiline = true;
Load += new System.EventHandler(MyForm_Load);
Paint += new PaintEventHandler(MyHandler);
}
// Load で呼ばれるメソッド
private void MyForm_Load(object sender, System.EventArgs e)
{ int i,j,k;
byte al,ah;
wstr = "";
for(i=0; i<str.Length; i+=16)
{ j = str.Length-i;
if (j > 16) j = 16;
for(k=0; k<j; k++)
{ ah= (byte)(str[i+k]>>8);
al= (byte)str[i+k];
wstr+= al.ToString("X2");
wstr+= ah.ToString("X2");
if (k % 4 == 3) wstr += " ";
}
wstr += "\r\n";
wstr+= str.Substring(i,j);
wstr+= "\r\n";
}
}
// Paint で呼ばれるメソッド
private void MyHandler(object sender, PaintEventArgs e)
{
textBox1.Text = wstr;
}
}
class form01
{
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|
![]()