计算属性中的电话类型

时间:2013-04-05 01:53:43

标签: vb.net visual-studio-2010 visual-studio-lightswitch

在以下代码示例中,[MainSwitchBoardPhone]的属性类型为“Phone”。当我将计算的ClinicHospitalAddress属性设置为实体的摘要属性时,我希望电话号码显示在数据输入屏幕中,格式为(555)555-5555,而不仅仅是一个字符串。即5555555555.有办法做到这一点吗?

Private Sub ClinicHospitalAddress_Compute(ByRef result As String)
  ' Set result to the desired field value
  result = [ClinicHospital] & " " & [StreetAddress] & ", " & _
           [City] & " " & [MainSwitchBoardPhone]

2 个答案:

答案 0 :(得分:0)

如下:

result = [ClinicHospital] & " " & [StreetAddress] & ", " & _

[城市]& “”&格式([MainSwitchBoardPhone],“(###)### - ####”)

答案 1 :(得分:0)

尝试:

result = String.Format("{0} {1}, {2} (###) ###-####" _
    , [ClinicHospital] _
    , [StreetAddress] _
    , [City] _
    , Convert.ToInt64([MainSwitchBoardPhone]) _
    )

编辑:添加了Convert.ToInt64