Skip to main content

Posts

Showing posts with the label indexof

convert time 24 To 12 in asp.net

 If you want to convert time  24 format  To 12  am pm form in asp.net then you can try following method. You can write this method in common class in asp.net program then you can call this function by passing time variable in function parameter. public static string convert24To12(string time) { if (time.IndexOf(":") == -1) return time; string appendstring = "AM"; string strHr = time.Substring(0, time.IndexOf(":")); string strMin = time.Substring(time.IndexOf(":") + 1); int intHr = Convert.ToInt16(strHr); if (intHr > 12) { appendstring = "PM"; intHr -= 12; } if (intHr == 12) { appendstring = "PM"; } else if (intHr == 0) { intHr = 0; } return ((intHr < 10) ? "0" : "") + intHr + ":" + strMin + "...

Trim string from sentence,Use of Trim in different Ways in excel

Trim string from sentence in excel Public Function trimtwo(ByVal r As Range) As String Dim str As String str = r(1, 1) Dim Flag As Boolean Flag = False Dim indexof As Integer indexof = InStr(str, "Shri") If indexof Then str = Mid(str, indexof + 4, Len(str)) Flag = True End If indexof = InStr(str, "SHRI") If indexof Then str = Mid(str, indexof + 4, Len(str)) Flag = True End If indexof = InStr(str, "Smt.") If indexof Then 'str = Mid(str, 1, 1) & Mid(str, indexof + 5, Len(str)) str = Mid(str, indexof + 5, Len(str)) Flag = True End If indexof = InStr(str, ",") If indexof Then str = Mid(str, 1, indexof - 1) End If str = Trim(str) If Flag Then indexof = InStr(str, " ") If indexof Then str = Mid(str, 1, indexof - 1) & Mid(str, indexof + 1, Len(str)) End If End If trimtwo = str End Function Public Function trimone(ByVal r As...