问题描述:

why wont this work, I am trying to format the phone as a standard

Dim Patient = From line In System.IO.File.ReadAllLines("K:\PAT02.txt")

Select New With { _

Key .PatientID = line.substring(0,7).trim, _

.FirstName = line.substring(7,11).trim, _

.MiddleName = line.substring(18,1).trim, _

.LastName = line.substring(19,15).trim, _

.Home = (String.Format("{0:(###)###-####}", line.substring(112,10).trim)), _

}

网友答案:

You have an extra comma at the end of your New With block, remove it and your code will compile.

About your phone number problem, you're using number formatting, so you must pass a number to the String.Format method:

.Home = String.Format("{0:(###)###-####}", CLng(line.substring(112,10).trim))
相关阅读:
Top