|
I'm new to the VB.NET world so any help will be appreciated. I'm building a Windows app and I have a form with tabs. On the first tab, I'm building a search capability. I have a couple of text boxes and a data grid. Everything seems to work OK, however in my datagrid, one of the columns displays a social security number. My problem is I cant figure out how to format the SSN column to display with dashes. Right now it displays as '#########' and I need it to display "###-##-####'
Thank you in advance for any help.
|
|
|
|
|
LMJ
I'm also a newbie, but have come across this in VS2005. Use the 'Masked Textbox' and specify a mask or 000-00-0000.
If this control is not a part of your version of VS, you can convert the SS number to a string (tostring) and parse it using 'substring'
Dim sParse as String<br />
Dim sSS as String = ""<br />
sParse = iSSnumber.tostring<br />
sSS = sParse.substring(0,3) + "-"<br />
sSS += sParse.substring(3,2) + "-"<br />
sSS += sParse.substring(5,4)
Hope this is right,
Karen
*** Nooobie to OOP and VB.Net 2005
|
|
|
|
|
Take a look at this[^] article here on CP. The code is in C#, but if you look close enough, you'll see that it is easily convertible to VB.NET.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've edited the normal.dot file to add certain styles to documents created in Word 2003. These styles would only worked in new documents and not old ones. I created a macro and attached it to a toolbar button, which will add these styles to any documnet whether they are newly created documents or not. Yet my dilemma, is having the styles in this newly created normal.dot file activate no matter who's logged in to the system. I was worndering if there's a Currentuser or username variable that would accomplish this task for me. Any help would be greatly appreciated.
Thank you,
The VB Newbie
|
|
|
|
|
I want to do the following.
I have a tab control with 3 tab pages. When I click on the say tab 1, then a procedure automatically starts.
If I put the procedure in say, TabPage2_Click, then I have to physically click on the tab. What I am aiming for is that when I click the tabPage of the Tab Control, the procedure automatically runs.
I have been trying various ways using TabControl1.TabPages(1) but with no success. I know this must be a simply process and I am missing something out.
|
|
|
|
|
Have you tried combining all the tabpage handlers into one event handler?
See the "Handles" clause at the end of your TabPage_Click event handler. You can add a comma then the next object and event that this code will handle. When any of the classes in the Handles list fire's it's Click event, this handler will be called.
Public Sub TabPage_Click(...,...) Handles TabPage1.Click, TabPage2.Click, TabPage3.Click
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi
i am a bigginner to this vb.net.i have a problem in inserting data programiticaly(without using wizard or server explorer)from vb.net application to sql data table.whatever i am inserting through vb.net is not updating in the table. i have searched from 2 months for this.please anybody help for this?please give sample code for this, (another question is i am using combo box in the application how to insert that?)
thanking you.
|
|
|
|
|
You posted this very question an hour ago? Don't repost, it's very rude and it won't get your question answered any faster.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Could somebody tells me the way to create string/array math using visual basic? Thank You!
|
|
|
|
|
What do you mean by a "string/array math"? This doesn't make any sense at all, so we couldn't even begin to tell you anything useful.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If you want to know about array of strings
Dim ArrayOfString(0 to 3) as String
Redim Preserver ArrayOfString(5)
ArrayOfString(0)="Put "
ArrayOfString(2)="What "
ArrayOfString(3)="You "
ArrayOfString(4)="to "
ArrayOfString(5)="Save."
Shoaib Nawaz
|
|
|
|
|
hi
i am a bigginner to this vb.net.i have a problem in inserting data programiticaly(without using wizard or server explorer)from vb.net application to sql data table.whatever i am inserting through vb.net is not updating in the table. i have searched from 2 months for this.please anybody help for this?please give sample code for this, (another question is i am using combo box in the application how to insert that?)
thanking you.
shyli
|
|
|
|
|
Without seeing your SQL update code, it's impossible to tell you what your doing wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Imports System.Data.SqlClient
Imports System.Data.DataTable
Imports System.Data.DataRow
Public Class Form1
Inherits System.Windows.Forms.Form
Dim flag As Integer
Dim custid As String
Dim dr As DataRow
Dim dt As DataTable
Dim DS As New DataSet
Dim Conn As SqlConnection = New SqlConnection
Dim CMD As SqlCommand = New SqlCommand
Dim DA As SqlDataAdapter = New SqlDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Conn As SqlConnection = New SqlConnection("workstation Id=SHAily;packet size=4096;integrated security=SSPI; data source=SHAILY; PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=customer")
Dim CMD As SqlCommand = New SqlCommand("select * from tablename ", Conn)
CMD.Connection = Conn
DA.SelectCommand = CMD
DA.Fill(DS, "details")
Textbox1.DataBindings.Add("Text", DS.Tables("tablename"), "CUSTID")
Combobox1.DataSource = DS.Tables("tablename ")
Combobox1.DisplayMember = " tablename "
Combobox1.ValueMember = "NAME"
Textbox2.DataBindings.Add("Text", DS.Tables("tablename “), "ADDRESS")
Textbox3.DataBindings.Add("Text", DS.Tables("tablename "), "PHONE")
Combobox2.DataSource = Ds.Tables("tablename ")
Combobox2.DisplayMember = " tablename "
Combobox2.ValueMember = "POBOX"
End Sub
Private Sub BTNADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BNADD.Click
dt = DS.Tables("tablename ")
Textbox1.Text = ""
Combobox1.Text = ""
Textbox2.Text = ""
Textbox3.Text = ""
Combobox2.Text = ""
flag = 1
Dim ctr, len As Integer
Dim custidval As String
len = (dt.Rows.Count - 1)
dr = dt.Rows(len)
custid = dr("CUSTID")
custidval = Mid(custid, 2, 3)
ctr = CInt(custidval)
If ctr >= 1 And ctr < 9 Then
ctr = ctr + 1
Textbox1.Text = "C00" & ctr
ElseIf ctr >= 9 And ctr < 99 Then
ctr = ctr + 1
Textbox1.Text = "C0" & ctr
ElseIf ctr >= 99 Then
ctr = ctr + 1
Textbox1.Text = "C" & ctr
End If
Textbox1.Enabled = True
End Sub
Private Sub BtnSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSAVE.Click
If flag = 1 Then
da.Fill(DS, " tablename ")
'Dim dt7 As New DataTable
'dt7 = DS7.Tables("tablename ")
'dr = dt7.NewRow()
'Dim i As Integer
'dr(0) = custid
'dr(1) = Combobox1.Text
' dr(2) = Textbox2.Text
'dr(3) = Textbox3.Text
'dr(4) = Combobox2.Text
' dt7.Rows.Add(dr)
Dim str As String
Dim Conn1 As SqlConnection = New SqlConnection("workstation Id=SHAILY;packet size=4096;integrated security=SSPI; data source=SHAILY; PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=customer")
'CMD.Connection = Conn
str = "INSERT INTO DETAILS '(CUSTID,NAME,ADDRESS,PHONE,POBOX)'+'VALUES(CUSTID,@NAMEBOX,@TBADDRESS,@TBPHONE,@POBOX)'"
Dim CMD1 As New SqlCommand(str, Conn1)
CMD1.Parameters.Add("TEXT", SqlDbType.Char, 8, "custid")
'par.SourceColumn = "custid"
'par.SourceVersion = DataRowVersion.Original
CMD1.Parameters.Add("TEXT", SqlDbType.VarChar, 50, "name")
CMD1.Parameters.Add("TEXT", SqlDbType.VarChar, 90, "address")
CMD1.Parameters.Add("TEXT", SqlDbType.Char, 10, "phone")
CMD1.Parameters.Add("TEXT", SqlDbType.Char, 10, "pobox")
Conn1.Open()
DA.InsertCommand = CMD1
ElseIf flag = 2 Then
DA.Fill(DS, " tablename ")
dt = DS2.Tables("tablename ")
dr = dt.Rows(0)
custid = TEXTBOX1.Text
dr = dt.Rows.Find(custid)
dr.BeginEdit()
dr(0) = custid
dr(1) = COMBOBOX1.Text
dr(2) =TEXTBOX2.Text
dr(3) = TEXTBOX3.Text
dr(4) = COMBOBOX2.Text
dr.EndEdit()
Dim DA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM tablename", Conn)
DA.UpdateCommand = New SqlCommand("UPDATE tablename SET Name = @Name " & _
"WHERE CUSTID = @CUSTID", Conn)
DA.UpdateCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 15, "Name")
Dim workParm As SqlParameter = DA.UpdateCommand.Parameters.Add("@CUSTID", SqlDbType.Int)
workParm.SourceColumn = "CUSTID"
workParm.SourceVersion = DataRowVersion.Original
Dim DS As DataSet = New DataSet
DS.Fill(DS, "tablename")
Dim cRow As DataRow = DS.Tables("tablename").Rows(0)
cRow("Name") = "New name"
End If
flag = 0
DA.Update(DS, "tablename")
DA.fill(DS,”tablename”)
MsgBox("data saved---")
End Sub
|
|
|
|
|
Hi All,
I need to show all the menu items in the form into treeview
but i am not able to get the menu name its only giving the
menu text. any methods are available to get the name of the
menuitem object.
reply me yaar!!
V.Gopi.
Easy Design Systems
Coimbatore
India
|
|
|
|
|
Are you sure there's no name property (I don't remember it by heart)?
Anyway, an easy way is give the tag property the same value of the name and recall that one.
|
|
|
|
|
Hi all,
can any one quickly tell me how can i change my button with an image of my choice and also to play a sound on mouse click and mouse over.
replies could be send directly to my email address described below.
Jennifer Wadhani
jenniferaahmed@yahoo.com
|
|
|
|
|
Hello
For changing the button picture you need to drag an imagelist on the form. Add as many images as you like in the imagelist. Now to show any image on the button you need to select the imagelist in button's 'imagelist' property. Now all the images you ve added in the imagelist are visible to your button. Use 'ImageIndex' property of the button to change the images.
_mubashir
|
|
|
|
|
For playing sound...use the following
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Public Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Public Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
' Use the following library
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
' call
PlaySound("FilePath And Name", 0, SND_NOSTOP)
_mubashir
|
|
|
|
|
Thanks mubashir, i will try n get bac to u, Thanks a lot dear to show ur concern.
Regards
Jennifer Wadhani
jenniferaahmed@yahoo.com
|
|
|
|
|
I want to write a Listening Music Program with VB.NET but I don't know what place I begin!
|
|
|
|
|
For playing sound...use the following
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Public Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Public Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
' Use the following library
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
' call
PlaySound("FilePath And Name", 0, SND_NOSTOP)
V.Gopi.
Easy Design Systems
Coimbatore
India
|
|
|
|
|
Hi guys.. ok, here is my situation. I am doing SQL database programming ith VS 2003. I did a sql database called 'test.adp'. In this DB there is two tables.. ONe is 'Customer', the other is 'Temp'. In both this tables is the field 'Name'.
Okay, let's say the field 'Name' under the table 'Customer' have only one data in text form called 'David' . In the 'Temp' table, there is no data in it.
Is it possible for me to create a button and put a command in it where it will open up the 'customer' table, extract that 'David' data and insert it into the 'Temp' table under the 'Name' Field? Can anyone give me a brief command example that can accomplish this? Thanz for your time..
|
|
|
|
|
OK I'm not trying to be a jerk, just being honest.
No one is going to answer this question because probably no one on this forum has the time or interest in teaching basic SQL and data access in VB.NET. If we did have the inclination, we would not have the time because we'd be busy with either teaching or writing a book.
That's just the basic truth.
Yes this is possible - you can use a SELECT query to get data from one table and an INSERT query to put it in the other. Or use about half a dozen other ways.
All of which require some basic understanding of SQL and data access. You have to learn that on your own.
Again I don't want to seem like a jerk, it's just reality. You can do it - nobody here will do it for you.
We all have to start somewhere, and I understand that the MSDN is not the place - it's just not useful until you reach a certain level.
But the same is true of this forum.
What you need at this point is a good reference book. A beginning book of any kind. If you feel like you are good with picking things up quickly, a beginner book may seem overly simple - in which case certification books often give more technical but useful overviews. To learn NET initially I used the MCSD 70-360 Exam book published by Que, authored by Mike Gunderloy. It is a great quick start. Costs you $50 new, but how much is your time worth?
If you don't have the money, or just want to look at something right now, here is freebie on the web - I don't think it is that great, but it is better than nothing:
http://www.interplat.com/VBNet.pdf[^]
Godd Luck .... seriously
|
|
|
|
|
Been through that book, it doesn't go through SQL database programming. Select and Insert Command.. We are getting somewhere eventually.. Beasically, I am not asking anyone to write the whole code down for me. as Mentioned on the starting thread, I gave a small example of what I am trying to do and hopefully, someone out there who is helpful enough and have some spare time in his hands can help out.. This is what this thread is for, after all..
So anyone else with some knowledge on this and is willing to help... Will appreciate your time...
|
|
|
|
|