Link to home
Start Free TrialLog in
Avatar of prowebinteractiveinc
prowebinteractiveinc

asked on

.NET string

I have a string that is given to me as a XML POST response from another server. its a delimited string, I have already tokenized the string.

so now I have for example

firstName=john
lastName=Smith
telephone=514-555-1234
email=jsmith@email.com

what I would like to do is
create some kind of table so they are aligned, I was thing plain labels but im sure there is a better way then this.
Im looking for this:

First Name:   John
Last Name:   Smith
Telephone:   514-555-1234
Email:            jsmith@email.com
Avatar of mwochnick
mwochnick
Flag of United States of America image

what/where do you want to display the table?  web page, file, etc?
Avatar of kaufmed
What kind of project is this? WinForms? ASP.NET?
Avatar of prowebinteractiveinc
prowebinteractiveinc

ASKER

windows forms
I need to create the textboxes dyanically, strings could change, I could get more variables or less.. so for every

variableName=variable I need 2 textboxes on for the variableName, nad one for the variable, I will worry about the design/look later
ASKER CERTIFIED SOLUTION
Avatar of Ron Malmstead
Ron Malmstead
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Add a TableLayoutPanel to your form. At runtime, instantiate your controls using the new keyword. Add them to the tableLayoutPanel.Controls collection. You can either add them to specific rows and columns, or let panel have them flow into the next available cell.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what is the vbcrlf  ?

Dim Fields as String() = FieldData.Split(vbcrlf)

Open in new window

vbCrLf is a constant that stands for "Carriage Return/Line Feed". The code snippet is breaking up the FieldData string so that each line ends up as a separate entry in the Fields array.
I seem to have the string cut up, the problem through is the variable name shows up as firstName, is there a way to change it to First Name, or Name, or as anything I want really

so you know what route I took..

I used the logic of the logic for the splitting xuserx2000 and then put in a DataGridView exactly like Idle_Mind said
I was thinking of creating an array of the names I want, I know how to do this in PHP but in .NET, I need alittle help
here is some example for how to use xmlReader and how grab the content of an XML document
http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx#Y0
it has both c#.NET and VB.NET examples.  It links to more in depth examples on how to do specific actions

Here's an a document on how to create and populate an array with values
http://msdn.microsoft.com/en-us/library/wak0wfyt.aspx
and here's c# tutorial on arrays
http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx
"the variable name shows up as firstName, is there a way to change it to First Name, or Name"

You can find the all the Capital letters in the string and add a space before each one:
        Dim data As String = "firstName"
        data = FormatValue(data)
        Debug.Print(data)

Open in new window


Using this function:
    Private Function FormatValue(ByVal str As String) As String
        Dim SB As New System.Text.StringBuilder(str)

        If SB.Length > 0 Then
            ' make sure the first letter is capitalized
            SB(0) = Char.ToUpper(SB.Chars(0))

            ' Working backwards, add a space before each capital letter found:
            For i As Integer = SB.Length - 1 To 1 Step -1
                If Char.IsUpper(SB.Chars(i)) Then
                    SB.Insert(i, " ")
                End If
            Next
        End If

        Return SB.ToString.Trim
    End Function

Open in new window