i am making a project in vb.net and i have a bio data form in it
i have 2 textbox in it, TextBox1 is for Name and the Textbox2 is for father's name . i want to make the first letters of Name in textBox1 as Capital(eg: Pratik Shukla) in both the TextBox .on focus lost
OK, you will need to use the UCase, and mid functions simply like this:
Function GetFormattedName AS String dim FormattedName as string ="" dim FirstName as String ="" dim LastName as String ="" if trim(Textbox1.text) <> "" then Firstname = trim(Textbox1.text) end if if trim(Textbox2.text) <> "" then Lastname = trim(Textbox2.text) end if If Firstname <>"" then 'Fully formatted Name Uppercase First char Lowercase the rest and add a space FormattedName = UCASE(mid(FirstName,1,1)) & lcase(mid(FirstName,2)) &" " end if If LastName <> "" then 'Append last name in the correct format as above FormattedName = FormattedName & UCASE(mid(LastName,1,1)) &lcase(mid(LastName,2)) End If GetFormattedName = trim(FormattedName) 'If we did not get any values we will get an empty string 'If we only got FirstName, the trim will strip out the trailing space. End Function
You could use the TextChanged property of the textboxes. This code will change all first letters to upper case (ProperCase) as soon as text is put into your textboxes. Instead of ProperCase, UpperCase or Lowercase can also be used.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged If TextBox1.Text <> "" Then Dim a As String = TextBox1.Text TextBox1.Text = (StrConv(a, VbStrConv.ProperCase)) TextBox1.Select(TextBox1.Text.Length, 0) End If If TextBox2.Text <> "" Then Dim a As String = TextBox2.Text TextBox2.Text = (StrConv(a, VbStrConv.ProperCase)) TextBox2.Select(TextBox2.Text.Length, 0) End If End Sub
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Private Sub btn_addline_Click(ByVal ...