One column in DataGrid is a display date, but the designer inserts a continuous string in the database, now requires the format of 2004/08/03 23:16:16 in DataGIRD, there are several ideas: Modify in the data set, then write back the dataset, the other is to write a SQL statement, then directly modify the data set, then write the data set, and finally use a simpler method to directly modify the output of DataGIRD. Write a function:
Private Function Formator (Byval Strin As String) AS String Dim Strrtn As String = "" Strrtn = Left (Strin, 4) & "/" Strrtn = MID (Strin, 5, 2) & "/" Strrtn = MID ( Strin, 7, 2) & "Strrtn = MID (STRIN, 9, 2) &": "Strrtn = MID (Strin, 11, 2) &": "Strrtn = MID (Strin, 13, 2) Return Strrtn End Function
Finally insert this function in DataBing ()
For i = 0 to me.datagrid1.items.count - 1 DataGrid1.items (i) .cells (1) .text = formatdate (DataGrid1.Items (i) .Cells (1) .text) Next