|
I recently moved from VB6 to Visual C#.NET and need to know how I can access the functionality of VB's InStr (InString) function and also the Left, Mid, and Right functions. For example, how can I do in C# what the following VB code does in separating a First name and Last name in a string in order to repopulate text controls on the form with the names separated?
Dim nPos As Integer 'Used in separating the values of first,last names based on the location of a 'space' character.
Dim strFullName As String 'Contains the person's complete name being retrieved.
'Begin by separating the First name from the Last name in the RecordSet 'and write their values back to their respective screen controls
nPos = InStr(1, strFullName, " ", vbTextCompare) If nPos > 0 Then frmMain.txtFirstname = Left(strFullName, nPos - 1) frmMain.txtLastname = Right(strFullName, Len(strFullName) - (nPos - 1)) frmMain.txtLastname = Trim$(Right(strFullName, Len(strFullName) - nPos)) End If
I would also like to know how to use an equivalent of VB's Left,Mid,Right string functions in C#. Thank you.
![Hmm [^o)]](/emoticons/emotion-40.gif)
|