TPFWebmaster
Members-
Content Count
13 -
Joined
-
Last visited
About TPFWebmaster
-
Rank
Newbie [Level 1]
-
Monocholise started following TPFWebmaster
-
Fetch Data From A Database And Display It In A For
TPFWebmaster replied to kvarnerexpress's topic in Programming
Database ObjectThe first thing you must do in your application is to open a database where your tables are stored. You need to declare a variable to hold your database in order to do this. This is done with: Dim dbMyDB As Database This gives you a variable/object that can hold a reference to your database. To open a simple Access database named "MyDatabase.mdb", do this: Set dbMyDB = OpenDatabase("MyDatabase.mdb")You should really specify the complete path to the db, but if your current directory is the directory where the database is situated, this will work. So, now you have opened a database. This won't give you any data. What you need to do is open a table in the database. RecordSet Object Visual Basic uses an object called RecordSet to hold your table. To declare such an object and to open the table, do this: Dim rsMyRS As RecordSetSet rsMyRS = dbMyDB.OpenRecordSet("MyTable", dbOpenDynaset)What happened there? Well, I declared a RecordSet object and used the Database object's OpenRecordSet method to open a table of type Dynaset. You can open a RecordSet in several modes. VB's online help file explains the different modes and what they ar e for. The Dynaset mode is the mode I use mostly. It gives you a RecordSet that you can add, delete and modify records in. Accessing records Now that we have opened a table (referred to as RecordSet from now on) we want to access the records in it. The RecordSet object allows us to move in it by using the methods MoveFirst, MoveNext, MovePrevious, MoveLast (among others). I will use some of these to fill up a list box with the records of our RecordSet. To get this example to work, make a database (with Access) called "MyDatabase.mdb" with the table "MyTable" in it. This table should have the fields "ID" of type "AutoNumber" that you set to be the primary key, the field "Name" of type Text and a field "Phone" of type Text. Add some records to it. Put a list box on a form and call it "lstRecords". Dim dbMyDB As DatabaseDim rsMyRS As RecordSetPrivate Sub Form_Load()Set dbMyDB = OpenDatabase("MyDatabase.mdb")Set rsMyRS = dbMyDB.OpenRecordSet("MyTable", dbOpenDynaset)If Not rsMyRS.EOF Then rsMyRS.MoveFirstDo While Not rsMyRS.EOF lstRecords.AddItem rsMyRS!Name lstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!ID rsMyRS.MoveNextLoopEnd SubThis will make the list box fill up with your records when the form loads. I have introduced some new concepts with this example. We have all ready covered the first part where we open the table. The line that says If Not rsMyRS.EOF Then rsMyRS.M oveFirst tells the program to move to the first record in case there are any records at all. The EOF is a Boolean property that is true if the current record is the last. It is also true if there are no records in the RecordSet. Then we make the program add the "Name" field of all records to the list box by adding the current records field "Name" and moving to the next record. You ask for a field of a RecordSet by putting a ! between the name of the RecordSet object and the na me of the field. The while loop checks to see if there are more records to add. Searching the RecordSet You might have wondered why I put the value of the field "ID" in the list box's ItemData property. I did this so that we would know the primary key for all the records in order to search for a record. Put a text box somewhere on the form and call it "txtPhone". Then copy the following code to the project. Private Sub lstRecords_Click()rsMyRS.FindFirst "ID=" & Str(lstRecords.ItemData(lstRecords.ListIndex))txtPhone.Text = rsMyRS!PhoneEnd SubThis will display the phone number of the selected person when clicking in the list box. It uses the FindFirst method of the RecordSet object. This takes a string parameter that is like what is after WHERE in a SQL expression. You state the field that you want to search in (here "ID"), then the evaluation criteria (here "=") and last the value to search for (here the ItemData of the selected item in the list box). So what we did was to search for the record with the "ID" field value that was the same as the ItemData property of the selected item in the list box. Then we show the value of the "Phone" field in the text box. Updating the Database You will probably want to update some value of some field when doing database programming. This is done with Edit and Update. We will try to change the value of the "Phone" field by editing the text in the text box and clicking a button. Put a command button on the form and name it "cmdUpdate". Then copy the following code to the project. Private Sub cmdUpdate_Click()rsMyRS.EditrsMyRS!Phone = txtPhone.TextrsMyRS.UpdateEnd SubIt's that simple. This changes the phonenumber of our selected person. Or to put it technically: This changes the value of the "Phone" field of our current record. Imagine the current record being a set of boxes, with a field in each box. T he Edit method takes the lid off all of the boxes and Update puts them back on. When we write rsMyRS!Phone = txtPhone.Text we replace the content of the "Phone" box with the content in the text box. Deleting and Adding records Deleting Deleting records couldn't be simpler. To delete the current record you just invoke the Delete method of the RecordSet object. We will put this feature in our little project. Make one more command button named "cmdDelete" and the following code will do the work of deleting our currently selected person. Private Sub cmdDelete_Click()rsMyRS.DeletelstRecords.RemoveItem lstRecords.ListIndexEnd Sub The first statement deletes the record and the second removes the list box entry. Adding Adding records is much like updateing, except you use AddNew instead of Edit. Let's add one more command button to our application. Let's call it "cmdNew". Here is the code that adds a new record. Private Sub cmdNew_Click()rsMyRS.AddNewrsMyRS!Name = "A New Person"lstRecords.AddItem rsMyRS!NamelstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!IDrsMyRS!Phone = "Person's Phone Number"rsMyRS.UpdateEnd SubI will use the box analogy to explain this. The AddNew method takes a set of new boxes and adds them to our RecordSet. We then put some new values in them and close the lids with Update. As you can see we never stated any valu e for "ID", but as you remember, this is a field of type "Counter" wich automatically gets a unique value. The code also adds this new record to the list box so that we will be able to change the phone number of this person. -
Key Loggers are definitely on the verge of illegality. Certainly, they deprive the user of his/her privacy, and should not be used at all. However, a keylogger is very simple to make. I'll give you a teeny-weeny hint. If you want the code then pm me stating the reason for it. Hint: Forms can be hidden but active on the screen. There is a code to reproduce the keystrokes.
-
here's the code for that. Make a module, Module1, and type (or copy-paste) the following code in it: Option ExplicitPrivate Type CWPSTRUCT lParam As Long wParam As Long message As Long hwnd As LongEnd TypePrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As LongPrivate Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongPrivate Const WH_CALLWNDPROC = 4Private Const GWL_WNDPROC = (-4)Private Const WM_CTLCOLORBTN = &H135Private Const WM_DESTROY = &H2Private Const WM_SETTEXT = &HCPrivate Const WM_CREATE = &H1Private lHook As LongPrivate lPrevWnd As LongPrivate bCustom As BooleanPrivate sButtons() As StringPrivate lButton As LongPrivate sHwnd As StringPublic Function SubMsgBox(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim sText As String Select Case Msg Case WM_CTLCOLORBTN 'Customize the MessageBox Buttons if neccessary.. 'First Process the Default Action of the Message (Draw the Button) SubMsgBox = CallWindowProc(lPrevWnd, hwnd, Msg, wParam, ByVal lParam) 'Now Change the Button Text if Required If Not bCustom Then Exit Function If lButton = 0 Then sHwnd = "" 'If this Button has Been Modified Already then Exit If InStr(sHwnd, " " & Trim(Str(lParam)) & " ") Then Exit Function sText = sButtons(lButton) sHwnd = sHwnd & " " & Trim(Str(lParam)) & " " lButton = lButton + 1 'Modify the Button Text SendMessage lParam, WM_SETTEXT, Len(sText), ByVal sText Exit Function Case WM_DESTROY 'Remove the MsgBox Subclassing Call SetWindowLong(hwnd, GWL_WNDPROC, lPrevWnd) End Select SubMsgBox = CallWindowProc(lPrevWnd, hwnd, Msg, wParam, ByVal lParam)End FunctionPrivate Function HookWindow(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim tCWP As CWPSTRUCT Dim sClass As String 'This is where you need to Hook the Messagebox CopyMemory tCWP, ByVal lParam, Len(tCWP) If tCWP.message = WM_CREATE Then sClass = Space(255) sClass = Left(sClass, GetClassName(tCWP.hwnd, ByVal sClass, 255)) If sClass = "#32770" Then 'Subclass the Messagebox as it's created lPrevWnd = SetWindowLong(tCWP.hwnd, GWL_WNDPROC, AddressOf SubMsgBox) End If End If HookWindow = CallNextHookEx(lHook, nCode, wParam, ByVal lParam)End FunctionPublic Function MsgBoxEx(ByVal Prompt As String, Optional ByVal Buttons As Long = vbOKOnly, Optional ByVal Title As String, Optional ByVal HelpFile As String, Optional ByVal Context As Long, Optional ByRef CustomButtons As Variant) As Long Dim lReturn As Long bCustom = (Buttons = vbCustom) If bCustom And IsMissing(CustomButtons) Then MsgBox "When using the Custom option you need to supply some Buttons in the ""CustomButtons"" Argument.", vbExclamation + vbOKOnly, "Error" Exit Function End If lHook = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf HookWindow, App.hInstance, App.ThreadID) 'Set the Defaults If Len(Title) = 0 Then Title = App.Title If bCustom Then 'User wants to use own Button Titles.. If TypeName(CustomButtons) = "String" Then ReDim sButtons(0) sButtons(0) = CustomButtons Buttons = 0 Else sButtons = CustomButtons Buttons = UBound(sButtons) End If End If lButton = 0 'Show the Modified MsgBox lReturn = MsgBox(Prompt, Buttons, Title, HelpFile, Context) Call UnhookWindowsHookEx(lHook) 'If it's a Custom Button MsgBox, Alter the Return Value If bCustom Then lReturn = lReturn - (UBound(CustomButtons) + 1) bCustom = False MsgBoxEx = lReturnEnd Function The code for creating the custom button will be: Dim aButtons(0) As String aButtons(0) = "Go"z = aButtons(MsgBoxEx("Text", vbCustom, "Title", , , aButtons))Do whatever you feel like with that 'z' in the code.
-
Actually, the '"extra" junk' that you are referring to is very very useful. Take these:- Prebuilt Features: CD-Burning: Windows 98-NO Windows XP-YES Support for .zip, .cab: Windows 98-NO Windows XP-YES Grant certain access rights to users: Windows 98-NO Windows XP-YES Not Compatible with other version software: Windows 98-YES Windows XP-NO (compatibility feature) Still need reasons why WinXP is better? Secure Logon Ctrl-Alt-Delete shows hidden processes and message sending options. Great Themes Lock your toolbars More options after failure to boot and yes, it does display the Blue Scrren, but Windows 98 simply HANGS!!!
-
FlightGear Flight Simulator ----------------------------------------------- Flight gear is a marvellous free Flight Simulator. I just downloaded it a few days ago from The FlightGear Website. Don't be hesitatnt to download the full 69 MB, its worth the download time. an additional feature is that you can separately download additional aircraft and scenery as required. It also has a LiveUpdate feature which downloads scenery as you go. The Full Features are: FlightGear can run on Windows, Linux, Mac OS-X, FreeBSD, Solaris, and IRIX platforms FlightGear can model a wide variety of aircraft, allowing you to fly the 1903 Wright Flyer, strange flapping wing "ornithopters", a 747 and A320, various military jets, and several light singles. FlightGear has extremely smooth and fluid instrument animation that updates at the same rate as your out-the-window view updates A multi player protocol is available for using FlightGear on a local network in a multi aircraft environment. The powerful network options make it possible to synchronize several instances of FlightGear allowing for a multi-display, or even a cave environment. Screenshots: San Francisco Screenshots: Three very nice Airplanes: Alcatraz Island and a flyover: Cessena 172 Cockpit:
-
Tips And Tricks In Windows everything you know share with us...
TPFWebmaster replied to Tonny's topic in Software
How to make a toolbar containing shortcuts on any side of the screen!1. make a folder somewhere in your HDD and name it something appropiate ('Programs' etc.)2. R-Click on start menu and select Toolbars->New toolbar...3. Browse and select the folder.4. Drag the toolbar usingits 'handle' to any side of the screen (NOTE: you may need to UnSelect 'Lock the Taskbar' in the r-click menu before you see the handle)5. You can set many options by right clicking on the toolbarTO ADD PROGRAMS:Create their shortcuts in the folder you created in step 1 -
Well, You certainly don't know about Anvil. Anvil is a (plugin/software?)* that can be used to identify instruments in an mp3 file and convert it into MID. also, you can try making your own MID file using Microsoft's PlayIT! *uncorfimed about its category. it is included in IntelliScore opr something loike that which can conver mp3 to MID (trial software. can convert only one minute)
-
Creating Login To Your Web Site
TPFWebmaster replied to malish's topic in Websites and Web Designing
You can use Javascript to create logins for certain pages, such as member pages, while leaving others open-to-all. only thing is that a moderately experienced hacker can get all usernames and passwords. Use the following script and save in an external document: /*-------------------------------------------------------------------INSTRUCTIONS - Read Before Using ScriptIf you are using frames, the code referred to in steps 2 - 5 must be put in the pages displayed in the frames and NOT in the parent document.Step 1In the Usernames & Passwords section, configure the variables asindicated by the comments. Step 2:Add the following code to the <head> section of your login page: <script src="scripts/login.js"></script> Change "scripts/login.js" to reflect the correct path to this scriptfile on your server. Step 3:Add this code to the login page, at the place you want the loginpanel to show: <script language="JavaScript"> BuildPanel(); </script> Step 4:Add the following code to the <head> section of each page proctededby this script: <script src="scripts/login.js"></script> <script language="JavaScript"> checkCookie(); </script>Change "scripts/login.js" to reflect the correct path to the scriptfile on your server. Step 5: On the page that is to have the logout button, paste this code where youwant the button to be: <form action="" name="frmLogoff"> <input type="button" name="btLogoff" value="log out" onclick="logout();"> </form> To use your own image instead of the grey button change the type from button to image and add src="myimage.gif" where myimage.gif is the image (including the path to it if needed, you want to use. Step 6:Upload this script and your html pages to the relevant directorieson your server. *///----------------------------------------------------------------// Usernames, Passwords & User Pages - These require configuration.//----------------------------------------------------------------var successpage = "test.html"; // The page users go to after login, if they have no personal page.var loginpage = "logintest.html"; //Change this to the page the login panel is on.var imgSubmit = ""; //Change to the path to your login image,if you don't want the standard button, otherwise do not change.var imgReset = ""; //Change to the path to your reset image,if you don't want the standard button, otherwise do not change.var users = new Array();users[0] = new Array("username1","password1","member1.html"); // Change these two entries to valid logins.users[1] = new Array("username2","password2","member2.html");// Add addtional logins, straight after these, as// required, followig the same format. Increment the // numbers in the square brackets, in new each one. Note:// the 3rd parameter is the the page that user goes to// after successful login. Ensure the paths are correct.// Make this "" if user has no personal page.//----------------------------------------------------------------// Login Functions//----------------------------------------------------------------function login(username,password){ var member = null; var loggedin = 0; var members = users.length; for(x=0;x<members && !loggedin; x++){ if((username==users[x][0])&&(password==users[x][1])){ loggedin = 1; member = x; break; } } if(loggedin==1){ if(users[member][2] != "") { successpage = users[member][2]; } setCookie("login",1); if (top.location.href != location.href){ location.href = successpage; }else{ top.location.href = successpage; } }else{ alert('access denied'); // Insert a fail message. } }function logout() { deleteCookie("login"); if (top.location.href != location.href){ location.href = loginpage; }else{ top.location.href = loginpage; }}//----------------------------------------------------------------// Cookie Handler//----------------------------------------------------------------var ckTemp = document.cookie;function setCookie(name, value) { if (value != null && value != "") document.cookie=name + "=" + escape(value) + ";"; ckTemp = document.cookie; } function deleteCookie(name) { if (getCookie(name)) { document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; }}function getCookie(name) { var index = ckTemp.indexOf(name + "="); if(index == -1) return null; index = ckTemp.indexOf("=", index) + 1; var endstr = ckTemp.indexOf(";", index); if (endstr == -1) endstr = ckTemp.length; return unescape(ckTemp.substring(index, endstr)); } function checkCookie() { var temp = getCookie("login"); if(!temp==1) { alert('access denied'); // Rensert a fail message. if(top.location.href != location.href){ location.href = loginpage; }else{ top.location.href = loginpage; } }}//----------------------------------------------------------------// Login Panel//----------------------------------------------------------------function BuildPanel() {document.write('<form name="logon"><table align="left" border="0"><tr><td align="right">');document.write('<small><font face="Verdana">Username:</font></small></td>');document.write('<td><small><font face="Verdana"><input type="text" name="username" size="20"></font></small></td></tr>');document.write('<tr><td align="right"><small><font face="Verdana">Password:</font></small></td>');document.write('<td><small><font face="Verdana"><input type="password" name="password" size="20"></font></small></td></tr>');if(imgSubmit == ""){ document.write('<tr><td align="center" colspan="2"><p><input type="button" value="Logon" name="Logon" onclick="login(username.value,password.value)">'); } else { document.write('<tr><td align="center" colspan="2"><p><input type="image" src="'+imgSubmit+'" name="Logon" onclick="login(username.value,password.value)">');}if(imgReset == ""){ document.write('<input type="reset" value="Reset" name="Reset">');} else { document.write('<input type="image" src="'+imgReset+'" name="Reset" onclick="logon.reset();">');}document.write('</p></td></tr></table></form>');} you will be required to modify a few attributes but it is all clearly mentioned. Implement step 4 in all protected pages. -
Gmail Frustrates Me Service down for more than 24 hours
TPFWebmaster replied to Dragonfly's topic in The Internet
Actually, I , for one am not havng any trouble. Wait... Let me check my mail and return.......... Yup.. Mail working for me Try again from a different computer. Maybe that will help. -
Microsoft's AntiSpyware Beta is also good. It is really fast and propmpts before running scripts, registry files, etc. so that you can review each execution. Not only that, but it also removes history and protects your computer while it's on the internet. Also detects shell changes. It also has a liveUpdate feature, and can be set to scan while your PC is idle.
-
Msgbox Here is a simple way and lists of MsgBoxes.
TPFWebmaster replied to MarCrush's topic in Programming
here is the code for a yes/no/cancel msgbox ync = MsgBox("Click on yes or no or cancel", vbYesNoCancel + vbQuestion, "Title")If ync = vbYes Then'code goes hereElseIf ync = vbNo Then'code goes hereElseIf ync = vbCancel Then'code goes hereEnd If -
Cheapest Way To Learn Vb? i dont want to spend a lot of money
TPFWebmaster replied to alapidus's topic in Programming
There is an edition of Visual Basic called 'Visual Basic Control Cretion Edition'. It is absolutely free except that you cannot create EXE's. A good idea for learning VB -
What is an Optical Chip? Take a look at it this way: A normal networking chip can transmit a movie in about 2 hours (really fast). An optical chip odf the same size can transfer a movie in minutes (Super fast). A normal chip has around 18 channels, better ones have UPTO 40. An optical chip has 80 CHANNELS! We are looking at a potential breakthrough that can completely revolutionarize the age of computing. It is the Fifth Generation of Computers. Let me know if there an any other amazing facts about optical chips at my e-mail address: S_o_u_m_y_a_1_2_3@yahoo.co.uk