Friday, April 22, 2011

A Function : String convert to date. Date convert to string

बहुत  बार Programmer को problem होती है की Form पर डाटा तो display String में होने चाहिए और database में डाटा date format  में save होने चाहिए इस लिए ये दो function बनाये हे आप अपनी इच्छा अनुसार परिवर्तन करके काम में ले सकते है

Public Function StringCovDate(strDate As String, Optional styDate As Integer = 1) As Date

Dim t() As String
t = Split(strDate, "/")
Select Case styDate
    Case 1
        StringCovDate = DateSerial(CInt(t(2)), CInt(t(1)), CInt(t(0)))
    Case 2
        StringCovDate = DateSerial(CInt(t(2)), CInt(t(0)), CInt(t(1)))
    Case 3
        StringCovDate = DateSerial(CInt(t(0)), CInt(t(2)), CInt(t(3)))
End Select

End Function

Public Function DateCovString(sDate As Date, Optional styDate As Integer = 1) As String

Dim cuDate As String
    Select Case styDate
        Case 1
            cuDate = Format(sDate, "dd/MM/yyyy")
        Case 2
            cuDate = Format(sDate, "MM/dd/yyyy")
        Case 3
            cuDate = Format(sDate, "yyyy/MM/dd")
    End Select
DateCovString = cuDate

End Function

Tuesday, April 19, 2011

How to disable the Restore button a MDI form in VB 6?


Use in Modual :

Private Const WS_THICKFRAME As Long = &H40000
Private Declare Function GetWindowLong Lib _
"user32" Alias "GetWindowLongA" (ByVal _
hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib _
"user32" Alias "SetWindowLongA" (ByVal _
hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib _
"user32" (ByVal hwnd As Long, ByVal _
hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal _
cy As Long, ByVal wFlags As Long) As Long


'------------------------------------------------------------

Function DisableResBtn(frm As Form)
Const WS_THICKFRAME = &H40000
Const WS_MAXIMIZE = &H1000000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)
Const SWP_FRAMECHANGED = &H20
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
'Const HWND_TOP = 0

Dim nStyle As Long
Dim hwnd As Long
nStyle = GetWindowLong(frm.hwnd, GWL_STYLE)
nStyle = nStyle And Not (WS_THICKFRAME)
nStyle = nStyle And Not (WS_MAXIMIZE)
nStyle = nStyle And Not (WS_MAXIMIZEBOX)
Call SetWindowLong(frm.hwnd, GWL_STYLE, nStyle)
SetWindowPos frm.hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER

End Function
'------------------------------------------------------------------------
 

' This code use in MDI Form for Load Event

Private Sub MDIForm_Load()
  Call DisableResBtn(Me)
End Sub



लाडनूं तकनीकी समाचार आप का हार्दिक अभिनन्दन करते है