Option Explicit
Dim isShowGrid As Boolean
Dim isPageMore As Boolean
Public Sub LoadDatabase(strSQL As String)
' áÊ´§ÀÒ¾¹Ñ¡àÃÕ¹
'imgStudent.Picture = LoadPicture(PICTURE_PATH & "00000.jpg")
strSQL = Trim$(strSQL)
Dim Wrk As Workspace
Dim Db As Database
Dim Rs As Recordset
Set Wrk = DBEngine.Workspaces(0)
Set Db = Wrk.OpenDatabase(DATABASE_PATH, False, False, ";PWD=")
Set Rs = Db.OpenRecordset(strSQL, dbOpenSnapshot)
Set datStudent.Recordset = Rs
If datStudent.Recordset.RecordCount < 1 Then
Exit Sub
End If
UpdateData
datStudent.Recordset.MoveFirst
Set Rs = Nothing
Set Db = Nothing
Set Rs = Nothing
End Sub
Public Sub UpdateData()
Dim strRoomID As String
Dim strNumberID As String
With Me
.txtAboutme.Text = " " & datStudent.Recordset.Aboutme
.txtAdd1.Text = " " & datStudent.Recordset.Add1
.txtAdd2.Text = " " & datStudent.Recordset.Add2
.txtAlter.Text = " " & datStudent.Recordset.Alter
txtBlood.Text = " " & datStudent.Recordset.Blood
If Trim(datStudent.Recordset.Bdate) <> "" Then
.txtBirthDate.Text = " " & datStudent.Recordset.Bdate & "/" & datStudent.Recordset.Bmonth & "/" & datStudent.Recordset.Byear
Else
.txtBirthDate.Text = " -"
End If
.txtClub.Text = " " & datStudent.Recordset.Club
.txtEmail.Text = " " & datStudent.Recordset.Email
.txtEx.Text = " " & datStudent.Recordset.Ex
.txtExprov.Text = " " & datStudent.Recordset.Exprov
.txtExt1.Text = " " & datStudent.Recordset.Ext1
.txtFan.Text = " " & datStudent.Recordset.Fan
.txtFcall.Text = " " & datStudent.Recordset.Fcall
.txtFeeling.Text = " " & datStudent.Recordset.Feeling
.txtFreestyle.Text = " " & datStudent.Recordset.Freestyle
.txtHomepage.Text = " " & datStudent.Recordset.Homepage
.txtID.Text = " " & datStudent.Recordset.ID
.txtJob.Text = " " & datStudent.Recordset.Job
.txtMotto.Text = " " & datStudent.Recordset.Motto
.txtJoke.Text = " " & datStudent.Recordset.Joke
.txtLike.Text = " " & datStudent.Recordset.Like
.txtM4.Text = " " & datStudent.Recordset.M4
.txtM5.Text = " " & datStudent.Recordset.M5
.txtM6.Text = " " & datStudent.Recordset.M6
.txtMobile.Text = " " & datStudent.Recordset.Mobile
.txtMsn.Text = " " & datStudent.Recordset.MSN
.txtNetname.Text = " " & datStudent.Recordset.Netname
.txtNname.Text = " " & datStudent.Recordset.Nname
If Trim(datStudent.Recordset.Fname) <> "" Then
.txtFullName.Text = " " & datStudent.Recordset.Prefix & " " & datStudent.Recordset.Fname & " " & datStudent.Recordset.Sname
Else
.txtFullName.Text = " -"
End If
If Val(datStudent.Recordset.program) > 11 Or Val(datStudent.Recordset.program) < 1 Then
.txtProgram.Text = " -"
Else
.txtProgram.Text = PROGRAMDATA(datStudent.Recordset.program)
End If
.txtProud.Text = " " & datStudent.Recordset.Proud
.txtRel.Text = " " & datStudent.Recordset.Rel
.txtSpecial.Text = " " & datStudent.Recordset.Special
.txtSubject.Text = " " & datStudent.Recordset.Subject
If Len(Trim(datStudent.Recordset.Tel1)) = 9 Then
txtTel1.Text = " " & Left(datStudent.Recordset.Tel1, 1) & "-" & Mid(datStudent.Recordset.Tel1, 2, 4) & "-" & Right(datStudent.Recordset.Tel1, 4)
Else
.txtTel1.Text = " -"
End If
If Len(Trim(datStudent.Recordset.Tel2)) = 9 Then
.txtTel2.Text = " (" & Left(datStudent.Recordset.Tel2, 3) & ") " & Mid(datStudent.Recordset.Tel2, 4, 3) & "-" & Right(datStudent.Recordset.Tel2, 3)
Else
.txtTel2.Text = " -"
End If
.txtTodo.Text = " " & datStudent.Recordset.Todo
.txtUniversity.Text = " " & datStudent.Recordset.University
End With
strRoomID = NumtoID(Val(datStudent.Recordset.room), 3)
strNumberID = NumtoID(Val(datStudent.Recordset.Number), 2)
LoadGalleryImage STUDENT_PATH & strRoomID & "\" & strRoomID & strNumberID & ".jpg", "Profile"
End Sub
Public Sub GoPrevious()
If datStudent.Recordset.RecordCount > 1 Then
datStudent.Recordset.MovePrevious
If datStudent.Recordset.BOF = True Then datStudent.Recordset.MoveNext
UpdateData
End If
End Sub
Public Sub GoNext()
If datStudent.Recordset.RecordCount > 1 Then
datStudent.Recordset.MoveNext
If datStudent.Recordset.EOF = True Then datStudent.Recordset.MovePrevious
UpdateData
End If
End Sub
Public Sub ControlRelocation()
Dim dx As Integer, dy As Integer
dx = (SCREEN_WIDTH - 800) / 2
dy = (SCREEN_HEIGHT - 600) / 2
flashProfile.Move dx, dy, 800, 600
With lblClass
.Move .Left + dx, .Top + dy
End With
With lblNumber
.Move .Left + dx, .Top + dy
End With
With lblFrom
.Move .Left + dx, .Top + dy
End With
With DBGrid1
.Move .Left + dx, .Top + dy - 1200
End With
With imgStudent
.Move .Left + dx, .Top + dy
End With
With txtFullName
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtNname
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtFcall
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtBirthDate
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtBlood
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtProgram
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtClub
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtM4
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtM5
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtM6
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtID
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtAdd1
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtTel1
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtExt1
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtAdd2
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtTel2
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtMobile
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtAlter
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtRel
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtEmail
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtMsn
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtHomepage
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtNetname
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtEx
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
With txtExprov
.Move .Left + dx, .Top + dy
.BackColor = vbWhite
End With
' ¨º¢éÍÁÙÅÊèǹáá àÃÔèÁ¢éÍÁÙÅÊèǹ·ÕèÊͧ
With txtUniversity
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtJob
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtMotto
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtJoke
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtProud
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtSpecial
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtFan
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtSubject
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtLike
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtTodo
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtAboutme
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtFeeling
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
With txtFreestyle
.Move .Left + dx, .Top + dy - 600
.BackColor = vbWhite
End With
'With
' .Move .Left + dx, .Top + dy
'End With
End Sub
Public Sub SetVisibleAll(TorF As Boolean)
With Me
.txtFullName.Visible = TorF
.txtNname.Visible = TorF
.txtFcall.Visible = TorF
.txtBlood.Visible = TorF
.txtProgram.Visible = TorF
.txtM4.Visible = TorF
.txtM5.Visible = TorF
.txtM6.Visible = TorF
.txtAdd1.Visible = TorF
.txtTel1.Visible = TorF
.txtAdd2.Visible = TorF
.txtTel2.Visible = TorF
.txtMobile.Visible = TorF
.txtAlter.Visible = TorF
.txtRel.Visible = TorF
.txtEmail.Visible = TorF
.txtMsn.Visible = TorF
.txtHomepage.Visible = TorF
.txtNetname.Visible = TorF
.txtEx.Visible = TorF
.txtExprov.Visible = TorF
.txtUniversity.Visible = TorF
.txtJob.Visible = TorF
.txtMotto.Visible = TorF
.txtJoke.Visible = TorF
.txtProud.Visible = TorF
.txtSpecial.Visible = TorF
.txtFan.Visible = TorF
.txtSubject.Visible = TorF
.txtLike.Visible = TorF
.txtTodo.Visible = TorF
.txtAboutme.Visible = TorF
.txtFeeling.Visible = TorF
.txtFreestyle.Visible = TorF
.txtBirthDate.Visible = TorF
.txtClub.Visible = TorF
.txtExt1.Visible = TorF
.txtID.Visible = TorF
.lblClass.Visible = TorF
.lblNumber.Visible = TorF
.lblFrom.Visible = TorF
End With
End Sub
Public Sub SwapToPage1()
SetVisibleAll (False)
With Me
.txtFullName.Visible = True
.txtNname.Visible = True
.txtFcall.Visible = True
.txtBlood.Visible = True
.txtProgram.Visible = True
.txtM4.Visible = True
.txtM5.Visible = True
.txtM6.Visible = True
.txtAdd1.Visible = True
.txtTel1.Visible = True
.txtAdd2.Visible = True
.txtTel2.Visible = True
.txtMobile.Visible = True
.txtAlter.Visible = True
.txtRel.Visible = True
.txtEmail.Visible = True
.txtMsn.Visible = True
.txtHomepage.Visible = True
.txtNetname.Visible = True
.txtEx.Visible = True
.txtExprov.Visible = True
.txtBirthDate.Visible = True
.txtID.Visible = True
.txtExt1.Visible = True
.txtClub.Visible = True
End With
End Sub
Public Sub SwapToPage2()
SetVisibleAll (False)
With Me
.txtUniversity.Visible = True
.txtJob.Visible = True
.txtMotto.Visible = True
.txtJoke.Visible = True
.txtProud.Visible = True
.txtSpecial.Visible = True
.txtFan.Visible = True
.txtSubject.Visible = True
.txtLike.Visible = True
.txtTodo.Visible = True
.txtAboutme.Visible = True
.txtFeeling.Visible = True
.txtFreestyle.Visible = True
End With
End Sub
Public Sub SwapGrid(toNormal As Boolean)
Dim dy As Integer
If toNormal Then
dy = -10000
Else
dy = 10000
End If
With txtFullName
.Top = .Top + dy
End With
With txtNname
.Top = .Top + dy
End With
With txtFcall
.Top = .Top + dy
End With
With txtBlood
.Top = .Top + dy
End With
With txtProgram
.Top = .Top + dy
End With
With txtM4
.Top = .Top + dy
End With
With txtM5
.Top = .Top + dy
End With
With txtM6
.Top = .Top + dy
End With
With txtAdd1
.Top = .Top + dy
End With
With txtTel1
.Top = .Top + dy
End With
With txtAdd2
.Top = .Top + dy
End With
With txtTel2
.Top = .Top + dy
End With
With txtMobile
.Top = .Top + dy
End With
With txtAlter
.Top = .Top + dy
End With
With txtRel
.Top = .Top + dy
End With
With txtEmail
.Top = .Top + dy
End With
With txtMsn
.Top = .Top + dy
End With
With txtHomepage
.Top = .Top + dy
End With
With txtNetname
.Top = .Top + dy
End With
With txtEx
.Top = .Top + dy
End With
With txtExprov
.Top = .Top + dy
End With
With txtBirthDate
.Top = .Top + dy
End With
With txtClub
.Top = .Top + dy
End With
With txtID
.Top = .Top + dy
End With
With txtExt1
.Top = .Top + dy
End With
' ¨º¢éÍÁÙÅÊèǹáá àÃÔèÁ¢éÍÁÙÅÊèǹ·ÕèÊͧ
With txtUniversity
.Top = .Top + dy
End With
With txtJob
.Top = .Top + dy
End With
With txtMotto
.Top = .Top + dy
End With
With txtJoke
.Top = .Top + dy
End With
With txtProud
.Top = .Top + dy
End With
With txtSpecial
.Top = .Top + dy
End With
With txtFan
.Top = .Top + dy
End With
With txtSubject
.Top = .Top + dy
End With
With txtLike
.Top = .Top + dy
End With
With txtTodo
.Top = .Top + dy
End With
With txtAboutme
.Top = .Top + dy
End With
With txtFeeling
.Top = .Top + dy
End With
With txtFreestyle
.Top = .Top + dy
End With
'With
' .Move .Left + dx, .Top + dy
'End With
End Sub
Private Sub Command6_Click()
End Sub
Private Sub Command7_Click()
isPageMore = Not isPageMore
If isPageMore Then
SwapToPage2
Else
SwapToPage1
End If
End Sub
Private Sub Command8_Click()
SwapToPage2
End Sub
Private Sub flashProfile_FSCommand(ByVal command As String, ByVal args As String)
Select Case command
Case "goto"
If args = "back" Then
GOTO_PAGE = "back"
Unload Me
ElseIf args = "main" Then
GOTO_PAGE = "main"
Unload Me
ElseIf args = "page1" Then
SwapToPage1
ElseIf args = "page2" Then
SwapToPage2
End If
Case "next"
GoNext
Case "prev"
GoPrevious
Case "grid"
isShowGrid = Not isShowGrid
SwapGrid (Not isShowGrid)
DBGrid1.Visible = isShowGrid
UpdateData
Case "ready"
imgStudent.Visible = True
SwapToPage1
End Select
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyRight Then
GoNext
ElseIf KeyCode = vbKeyLeft Then
GoPrevious
End If
End Sub
Private Sub Form_Load()
ControlRelocation
SetVisibleAll (False)
flashProfile.Movie = FLASH_PATH & "Profile.swf"
Do
DoEvents
Loop Until flashProfile.ReadyState = FLASH_COMPLETE
isShowGrid = False
isPageMore = False
End Sub
เออ ไม่มีไรหรอก ... เขียนโปรแกรมโง่ โค้ดมันก็เลยยาวอย่างที่เห้น
มีฟอร์มเชี่ยๆแบบนี้ประมาณสิบฟอร์ม ( แต่โค้ดฟอร์มนี้ถึกสุด )
กุจะอ่านหนังสือทันไม๊เนี่ย
ไปแระโว้ย
0aa81847-443f-40cd-80ad-1fdb21dbeb9a|0|.0