1 / 7

Visual Basic Text Boxes - Buttons

Visual Basic Text Boxes - Buttons

dwikatmo
Download Presentation

Visual Basic Text Boxes - Buttons

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. C CO OM MM MA AN ND D B BU UT TT TO ON NS S / /T TE EX XT TB BO OX XE ES S A AN N N NA AJ JA AH H N NA AT TI IO ON NA AL L U UN NI IV VE ER RS SI IT TY Y M MA AN NA AG GE EM ME EN NT T I IN NF FO OR RM MA AT TI IO ON N S SY YS ST TE EM MS S P PR RE EP PA AR RE ED D B BY Y : : M MO OH HA AM MM ME ED D A AB BD DE EL L K KH HA AL LE EQ Q D DW dwikatmo@najah.edu G+: dwikatmo@gmail.com www.facebook.com/dwikatmo WI IK KA AT T 1 14 4/ /0 01 1/ /2 20 01 19 9 V VI IS SU UA AL L B BA AS SI IC C. .N NE ET T B BU UT TT TO ON NS S A AN ND D T TE EX XB BO OX XE ES S 1 1. .P PR RO OP PE ER RT TI IE ES S 2 2. .E EV VE EN NT TS S 3 3. .M ME ET TH HO OD DS S AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:1 OF 7

  2. P PR RO OP PE ER RT TI IE ES S O OF F A A T TE EX XT TB BO OX X O OB BJ JE EC CT T A AS SS SU UM ME E W Property Name Locked Enabled Multiline ReadOnly Visible UseSystemPasswordCharT1.UseSystemPasswordChar = True TabStop T1.TabStop = True WordWrap T1.WordWrap =True RightToLeft T1.RightToLeft = RightToLeft.No PasswordChar T1. PasswordChar= "*" MaxLength T1.Maxlength =5 TabIndex T1.TabIndex = 0 Tag T1.tag=any Text (most used) T1.text = "Hello" ScrollBars T1.ScrollBars=ScrollBars.Horizontal T1.ScrollBars=ScrollBars.Vertical T1.ScrollBars=ScrollBars.Both T1.ScrollBars=ScrollBars.None TextAlign T1.TextAlign = HorizontalAlignment.Center T1.TextAlign = HorizontalAlignment. Left T1.TextAlign = HorizontalAlignment. Right Dock (ءاسرا) T1.Dock = DockStyle.Bottom DockStyle.Left, DockStyle. Right DockStyle. fill, DockStyle.Button DockStyle. top, DockStyle.none Forecolor T1.forecolor =color.red BackColor T1.BackColor = Color.Yellow Width T1.width=200 Height T1.height=200 TextLength T1.TextLength Notes: for PasswordChar to take effect, UseSystemPasswordChar should be set to False Note: For WordWrap and scrollbars to take effect, Multiline should be true For a TextBox named T1 Write a VB.net code to 1.set the Password mask to be & T1.UseSystemPasswordChar = False T1.PasswordChar= "&" 2.set the text Box accept Arabic properly in T1, And accept English properly in T2, where the code should be written T1.RightToLeft = RightToLeft.Yes T1.TextAlign = HorizontalAlignment.Right ‘for English write T2.RightToLeft = RightToLeft.No T2.TextAlign = HorizontalAlignment.Left WE E H HA AV VE E A A T TE EX XT TB BO OX X N NA AM ME E T T1 1 Code to change it Can’t be changed by code Can’t be changed by code T1.enabled =false T1.MultiLine=True T1.ReadOnly=True T1.visible =False Values True/False True/False True/False True/False True/False True/False True/False True/False True/False Yes/No Any Mask 0 unlimited Valid No. As Temp Any value Horizontal Vertical Both None Center Left Right Color.Name In pixels In pixels No of letters AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:2 OF 7

  3. The code is written in the GotFocus Event of each textbox 3.To set a textbox not accept more than 7 characters/numbers 4.Or to prevent textbox from accepting more than 7 characters/numbers T1.MaxLength = 7 E EV VE EN NT TS S O OF F A A T TE EX XT TB BO OX X Event When invoked TextChanged Any change in the content Click A click by a mouse/touch GotFocus Cursor arrives in the textbox LostFocus Cursor leaves the textbox KeyPress Any key is pressed from keyboard = KeyDown + KeyUp KeyDown Any key is pushed down KeyUp Any key is released up MouseClick A click by a mouse MouseDown When mouse is pushed down MouseUp When mouse is released up MouseEnter Mouse enters Textbox area MouseLeave Mouse leaves Textbox area MouseHover Mouse Hovers in Textbox area Where to write code of the event? Private Sub txtUserName_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtUserName.TextChanged 'here End Sub Jawwal Number is 10 numbers write a code to test if its length is correct, if not alert the user, set cursor back to T1 Private Sub T1_LostFocus(sender As Object, e As System.EventArgs) Handles T1.LostFocus If T1.TextLength < 10 Then MessageBox.Show("incorrect Jawwal Number") T1.Focus() End If End Sub M ME ET TH HO OS S O OF F A A T TE EX XT TB BO OX X Method usage comments Focus T1.focus() Go to T1/ cursor will set in T1 Copy T1.copy() Copy T1 contents or selected text Cut T1.cut() cut T1 contents or selected text Clear T1.clear() clear T1 contents SelectAll T1.SelectAll() Select all T1 contents DeselectAll T1.DeselectAll deselect T1 contents AppendText T1.AppendText("any") Add a text to T1 Undo T1.Undo() Undo changes in T1 Paste T1.Paste() Paste a text in T1 comments Most Used event = MouseDown + MouseUp AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:3 OF 7

  4. Note: Copy and cut will put the text in clipboard, while clear won’t. What the following code will do? How to read data from textboxes (Used as input) Dim s as string S = T1.text Dim Y as integer Y = val(T1.text) Dim d as date D = cdate(T1.text) AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:4 OF 7

  5. L LA AB BE EL LS S Labels inherit most of the TextBox properties, events and methods, except that it is different in appearance and read only (can’t be used as input). autoSize is a property of a label set to true or false if it is true the size of the label will increase automatically to fit the text inside the label. C CO OM MM MA AN ND D B BU UT TT TO ON NS S Command Buttons share most of the TextBox properties, events and methods, except that it is different in appearance and read only (can’t be used as input). Text property change the caption appear on the button, however, we can make a shortcut for the command button. What is the shortcut: it is a combination between Alt and a letter, in case of pressing it; it will invoke the click event (if no mouse exists) For example setting the text property to E&xit will appear as Exit, It means if a user presses Alt and X, it invoke the click method of that command Button. We can change it also using code cmdExit.text= "E&xit" Note: in the Notepad the shortcuts appear as follows (in menu) The same is applied for the command button If you press on alt+x , the same as clicking the button G GR RO OU UP P B BO OX X This is just a rectangle to group some controls together, it is used mainly for separating check boxes’ groups and radio buttons’ groups to be one block Properties : Text, RightToLeft, Dock, tag, visible etc.. C CH HE EC CK K B BO OX XE ES S These allow user to select multiple answers Here we have 5 checkboxes, assume the first one name is chkFacebook, then we can read its value by using the event CheckedChanged Facebook = chkFacebook.checkstate AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:5 OF 7

  6. If it is checked it has value of 1, if not checked, it has value of 0 Or as Boolean value Facebook = chkFacebook.checked If it is checked it has value of True, if not checked, it has value of False You can set its value also by using code chkFacebook.checked = true or chkFacebook.checked =false chkFacebook.checkstate =1 or chkFacebook.checkstate = 0 R RA AD DI IO O B BU UT TT TO ON NS S These allow user to select only one answer Here we have 2 radio buttons, assume their names are optMale and optFemale How to read their values? By using the event CheckedChanged Dim Male as Boolean Male = optMale.checked If it is checked it has value of True, if not checked, it has value of False You can set its value also by using code optMale.checked = true or optMale.checked = false L LI IN NK KE ED DL LA AB BE EL L It is like a label, but it has hyperlink. Properties Text : text appear on it Event LinkClicked Code Private Sub LinkLabel1_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked Process.Start("https://www.najah.edu/ar/") End Sub S ST TA AN ND DA AR RD D N NA AM MI IN NG G C CO ON NV VE EN NT TI IO ON NS S I IN N V VI IS SU UA AL L B BA AS SI IC C Control Example/Purpose form main TextBox Password TextBox Age CommandButton Save CommandButton Cancel label Password RadioButton Male CheckBox FaceBook comboBox ListBox Menu File Name frmMain txtPassword txtAge btnSave btnCancel lblPassword radMale chkFaceBook mnuFile prefix frm txt txt btn btn lbl rad chk cbo lst mnu AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:6 OF 7

  7. Following the standard naming conventions will have a great benefit in clearing ambiguity for the events when writing code btnSave,btnCancel.. txtUserName,txtPassword etc,.. chkMale, chkFemale .. mnuEdit, mnuCopy, mnuCut, mnuPaste.. AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:dwikatmo@gmail.com TOPIC:VISUAL BASIC II/TEXT BOXES /BUTTONS DATE:14/01/2019PAGE:7 OF 7

More Related