1 / 20

情報基礎実習 I ( 第 11 回)

情報基礎実習 I ( 第 11 回). 木 曜4・5限 担当 :北川 晃. 例題:金額の計算.  希望する商品すべてをクリックし,おのおのの個数を入力 したとき,合計金額を計算して表示するプログラムを作れ.. CheckBox. 金額の計算:プログラム例. Label1 ~ 3 , Textbox1 ~ 7 , Button1 , 2 の貼り付け. CheckBox1 ~ 6 の貼り付け. 金額の計算:プログラム例(つづき). Private Sub Button1_Click(sender As Object, e As EventArgs ) …

Download Presentation

情報基礎実習 I ( 第 11 回)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 情報基礎実習I(第11回) 木曜4・5限 担当:北川 晃

  2. 例題:金額の計算  希望する商品すべてをクリックし,おのおのの個数を入力 したとき,合計金額を計算して表示するプログラムを作れ. CheckBox

  3. 金額の計算:プログラム例 Label1~3,Textbox1~7,Button1,2の貼り付け CheckBox1~6の貼り付け

  4. 金額の計算:プログラム例(つづき) Private Sub Button1_Click(sender As Object, e As EventArgs) … Dim result As Integer = 0 If CheckBox1.Checked Then _ result = result + 150 * Val(TextBox1.Text) If CheckBox2.Checked Then _ result = result + 200 * Val(TextBox2.Text) … If CheckBox6.Checked Then _ result = result + 150 * Val(TextBox6.Text) TextBox7.Text = Format(result, "\\###,###") End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) … CheckBox1.Checked = False : TextBox1.Text = "" CheckBox2.Checked = False : TextBox2.Text = "" … CheckBox6.Checked = False : TextBox6.Text = "" End Sub 各チェックボックスが真か偽か 金額の表示の書式 各チェックボックスのチェックを外す

  5. 例題:論理ゲート  ラジオボタンで入力A,Bを指定し,ANDゲートもしくは ORゲート(ラジオボタンで選択)の演算結果をラジオボ タンで出力するプログラムを作れ. PictureBox

  6. 論理ゲート:画像の準備 PowerPointなどを 用いてAND回路, OR回路を作図

  7. 論理ゲート:画像の準備(つづき) 画像をPNG形式で保存

  8. 画像ファイル圧縮形式の特徴 • BMP(ビットマップ):ピクセル(画素)ごとにRGBで色の • 情報を記録する.圧縮なしの,基本的な形式. • GIF(ジフ):最大8ビット(256色)まで使える圧縮形式. • 透過GIFの作成や,アニメーションに用いられる. • “0000011111”→0*5, 1*5 “0101010101”→01*5 • JPEG(ジェーペグ):最大24ビット(1677万色)まで使える • 圧縮形式.人間の目が鈍感な色調変化の部分の • データを捨てる(不可逆変換)ことで圧縮を実現. • PNG(ピング):ライセンスに不安のあったGIF形式の代替. • 圧縮時にデータを捨てない,可逆変換を採用している.

  9. IfranView(画像閲覧,簡易加工) http://www.irfanview.com/ 画像の切り出し,簡易加工など

  10. IfranViewのダウンロード http://www.irfajview.com/ iview438_setup.exeをダウンロード

  11. IfranViewのセットアップ • iview438_setup.exeをダブルクリック,セットアップ • デスクトップ上のアイコンをダブルクリック 間もなく日本語パッチも準備されるはず

  12. IfranViewの起動 • PowerPointで作成したPNG形式のファイルを開く “Edit”メニューを選択 切り出す部分をマウスで選択 “File”→”Save As”で 名前を付けて保存 “Crop selection”を選択 (選択範囲を切り出す)

  13. 論理ゲート:プログラム例 RadioButton1~8, GroupBox1~3, Button1,2の貼り付け ① ⑧ ⑦ ② ⑤ ⑥ ③ ④ PictureBox1の貼り付け

  14. 論理ゲート:プログラム例 Dim a, b, c, op As Boolean If RadioButton7.Checked Then op = True If RadioButton8.Checked Then op = False If RadioButton1.Checked Then a = False If RadioButton2.Checked Then a = True If RadioButton3.Checked Then b = False If RadioButton4.Checked Then b = True If op Then PictureBox1.Image = Image.FromFile("D:\…\AND_gate.png") Else PictureBox1.Image = Image.FromFile("D:\…\OR_gate.png") End If 「動作」ボタン

  15. 論理ゲート:プログラム例(つづき) If op Then c = a And b Else c = a Or b End If If c Then RadioButton5.Checked = False RadioButton6.Checked = True Else RadioButton5.Checked = True RadioButton6.Checked = False End If 「動作」ボタン

  16. 論理ゲート:プログラム例(つづき) RadioButton1.Checked = False RadioButton2.Checked = False RadioButton3.Checked = False RadioButton4.Checked = False RadioButton5.Checked = False RadioButton6.Checked = False RadioButton7.Checked = True RadioButton8.Checked = False PictureBox1.Image = Nothing 「クリア」ボタン

  17. プログラミング演習 • 三角形の3辺a, b, cを読み込んで, • 三角形ができる場合は面積Sを計算せよ. A 三角形の成立条件 b c かつ C B ヘロンの公式 a ただし

  18. 三角形の面積:出力例

  19. 三角形の面積:プログラム例 Label1~4,TextBox1~4, Button1~3の貼り付け

  20. 三角形の面積:プログラム例(つづき) 「計算」ボタン Dim a, b, c, p, sAs Single a = Val(TextBox1.Text) b = Val(TextBox2.Text) c = Val(TextBox3.Text) If a = 0 Or (Math.Abs(a - b) > c Or a + b <= c) Then TextBox4.Text = "三角形にならない" Else p = (a + b + c) / 2 s = Math.Sqrt(p * (p - a) * (p - b) * (p - c)) TextBox4.Text = s End If

More Related