• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Manipulating VB strings in ASPX

Could someone point me to some string manipulation routines in VB? I've picked up a string variable with the following code in Page_Load:

    Public reason As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        reason = Request.Form("Reason")
     End Sub


 The full text for "Reason" , though,  is

                                           DECLINED:1101610001:Invalid account number

and I'd like to modify this to eliminate everything in front of the  ":" and use it in my HTML code with an embedded code block:

                            Transaction <%=reason %>

so the page reads

                          Transaction: invalid account number

Thanks for any ideas.
steva
0
steva
Asked:
steva
1 Solution
 
lorelogicCommented:
Use the Split Function

Public reason As String
private reasonArray () As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        reason = Request.Form("Reason")
      reasonArray () =  Split(reason, ":")
      reason = reasonArray(2)
     End Sub
0
 
stevaAuthor Commented:
Perfect!  

Thanks.
steva
0
 
skiltzCommented:
      Dim i As String = "DECLINED:1101610001:Invalid account number"
        Dim pattern As String = ".*:(?<code>.*)"

        Response.Write(Regex.Match(i, pattern).Groups("code").Value)


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now