水晶报告拆分字符串公式

问题描述:

我试图只显示字符串字段的日期部分。 这是字符串格式:STARTED:/ 03/23/1983 TIME:/ 03:12水晶报告拆分字符串公式

我需要删除“已启动:/”和“TIME:/ 03:12”,并只显示字符串的日期部分:03/23/1983。我可以用什么公式来做到这一点?

感谢

水晶报表帮助文件是你的朋友,应该对内置函数和数据类型简单的问题,你的第一站。

在CR字符串中存储为字符数组,因此您可以像索引一样访问它们。所以你的情况,如果你将永远有相同的字符串格式(即,相同数目的字符,前导零,等等),那么你可以做这样的事情:

local stringvar mystr := {table.your_string}; //mystr:="STARTED:/ 03/23/1983 TIME:/ 03:12" 
mystr[11 to 20] //return "03/23/1983"

或者,你可以使用Mid()字符串函数。

+0

感谢您的答复,因为我是新来的CR 。所以这将适用于任何记录。 – Dagz200 2012-07-28 20:25:16

+0

工作感谢您的帮助 – Dagz200 2012-07-28 21:36:02

我已经使用这个公式,全名的字符串分割成“姓”,字符串的其余部分连接起来作为“名”

 Dim string_array() As String 
     Dim i As Integer = 0 
     Dim ContactName As String = dt(0)("ContactName").ToString() 
     Dim contact_name As String 
     contact_name = String.Empty 
     If ContactName.Length = 0 Then 
      contact_name = String.Empty 
     Else 
      string_array = Split(ContactName, " ") 
      If string_array.Count > 1 Then 
       For i = 0 To string_array.Count - 2 
        If string_array(i) = String.Empty Then 
         Continue For 
        End If 
        contact_name = contact_name & " " & string_array(i) 
       Next 
      Else 
       contact_name = ContactName 
      End If 
     End If