บทที่ 3 การใช้งานคอนโทรล

290 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
290
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

บทที่ 3 การใช้งานคอนโทรล

  1. 1. 2
  2. 2. • Visual Studio • • • Label • TextBox ( ) • Button
  3. 3. Visual Studio 2008 • Start > All Programs > Microsoft Visual Basic
  4. 4. • Create Project File > New Project • Windows Forms Application
  5. 5. • Menubar • Standard Toolbar
  6. 6. • Solution Explorer
  7. 7. • Properties
  8. 8. • Toolbox
  9. 9. Form Textbox,But ton,
  10. 10. • Name • Bgcolor • BackgroundImage • Text • WindowState *** Properties
  11. 11. Form 1. Project> Add Windows Form 2. Windows Form
  12. 12. 1. Project> Properties 2.
  13. 13. Start Debugging Run • • Stop Debugging Stop
  14. 14. Label • Name • Font • Forecolor • Text • Visible *** label Properties
  15. 15. .text
  16. 16. Textbox • Name • BorderStyle • Enabled • Font • Forecolor • Maxlength • Multiline • Scorllbars • Text • Visible *** TextBox Properties
  17. 17. GUI
  18. 18. Button • Name • Backcolor • BackgroundImage • Font • Forecolor • Text • Visible *** Button Properties
  19. 19. code
  20. 20. Code
  21. 21. Name =TextBox1 Name =TextBox2 Name =TextBox3 Name =Button1 Name =Button2
  22. 22. Public Class Form1 // Dim a, b As Integer // a b Dim sum As Integer // sum Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click a = TextBox1.Text // TextBox1 a b = TextBox2.Text // TextBox1 b sum=a+b // a+b sum TextBox3.Text = sum // sum TextBox3.Text End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "“ // TextBox1.Text TextBox2.Text = "“ // TextBox2.Text
  23. 23. .checked
  24. 24. Radiobutton • Name • Checked • Enabled • Text *** RadioButton Properties
  25. 25. RadioButton
  26. 26. Click .Text
  27. 27. ComboBox • Name • Enabled • Item • Text *** ComboBox Properties
  28. 28. 4 Message Box
  29. 29. • • • MsgBox
  30. 30. Textbox Ucase UCase(“yao") Textbox1.text=Uca se(textbox1.text) YAO LCase LCase(“Yao") Textbox1.text=Lca se(textbox1.text) yao Trim Trim(" Hello ") Trim(" Hello ") Textbox1.text=Tri m(textbox1.text) Hello Len Len("AAA") Textbox1.text=Len (textbox1.text 3
  31. 31. textbox CInt Integer CInt("3000.457" ) Cint(textbox1.text ) 3000 CLng Long CLng("1000000 0") CLng(textbox1.tex t) 10000000 CCur Currency CCur("4598.897 6") CCur(textbox1.tex t) 4598.8976 Csng Single CSng("10000.71 17") CSng(textbox1.tex t) 10000.71 CDbl Double CDbl("10000.71 17") CDbltextbox1.text ) 10000.7117 CDate Date CDate("7 Jan 98"), CDate(56) CDate(textbox1.te xt) 1/7/98, 2/24/1900 CStr String CStr(975.7773) CStr(textbox1.text "975.7773"
  32. 32. Dim num1,num2 as integer Dim sum as integer Private sub button1 num1=textbox1.text num2=textbox2.text sum=num1+num2 textbox3.text=sum End sub Private sub button1 textbox3.text=Cint(te xtbox1.text)+Cint(tex tbox2.text) End sub
  33. 33. Date Time Now textbox.1.text=Now 10/17/98 6:42:33 PM Date textbox.1.text=date .today Time textbox.1.text=time string 6:42:33 PM
  34. 34. MessageBox • MessageBox MsgBoxMsgBox (“ msgbox”, button+ icon, “title”) Message Box
  35. 35. Msgboxstyle.Ok Only Msgboxstyle.Okc ancel Msgboxstyle.Yes No Msgboxstyle.Yes Nocancel Msgboxstyle.Ret
  36. 36. Msgbox
  37. 37. title icon Button
  38. 38. Msgboxstyle.Crit ical Msgboxstyle.Que stion Msgboxstyle.Excl amation Msgboxstyle.Inf ormation
  39. 39. Isnumer ic textbox true false If Isnumeric(textbox1. text) then Msgbox(“ ”) Textbox1.text=form at(cint(textbox1.tex t),”#,#.00”)
  40. 40. Format Textbox1.text=format (date.today,“long date”) 29 2556
  41. 41. 3%
  42. 42. 3% Comment
  43. 43. • •
  44. 44. • Date time • Date time
  45. 45. • Format • Format
  46. 46. • 3 •
  47. 47. • 3 2 • 7%
  48. 48. • (Code) , (Name) , (QTY), Typepro) • 2%,3%,5%
  49. 49. • - 2 25 - 1 - 2
  50. 50. Code • • Textbox (Code) , (Name) (QTY) Typepro) • (Price) • 200 15 • 200 – 500 12
  51. 51. • (Vat) 7% • (Discount) 15% • (NetAmount) • Clear • Exit
  52. 52. • Google keyword visual studio 2008 – http://wwwback.krirk.ac.th/thai4thai/BA2605_ web/VB_outline531.htm – http://gla.reru.ac.th/VB.php?menu=5 – http://pui.rru.ac.th/3601102/ • Visual Basic.Net

×