Clear all textboxes on a form at run-time

handy code for clearing all text box controls at run-timeso you don’t have to bother doing it at design time.http://137.56.41.168:2080/VisualBasicSource/vbworkingwithtextbox.txt Original Author: Found on the World Wide Web Code ‘make a new form; put some textboxen on it with some text in it’make a commandbutton’put the next code under the Command_Click event   Dim Control   For Each Control In Form1.Controls    … Read More »

Full example of Drag and Drop within a application

Suppose you have a listbox with some elements and want to drag&drop a selected one into a textbox. http://137.56.41.168:2080/VisualBasicSource/vbdraganddrop.txt Original Author: Found on the World Wide Web Code Make a form with a textbox (text1) and a listbox (list1). Fill the listbox with some items…Make a label (label1). Set it invisible = FalsePut the next code at the appropiate… Read More »

Getting a Reference to a VB?á5.0 UserControl

Visual Basic 5.0 allows you to use UserControls to create ActiveX controls in your projects. The following code snippet does two things: It gets a reference to the form in which a UserControl is placed, and it gets a reference to that control on the form. by David Mendlen Original Author: Found on the World Wide Web Code Dim PControl… Read More »

Get the name of a control at runtime

I’ve recently taken over a project from someone else, and I’ve been left with code that has few naming conventions and a lot of bugs. I often find myself stepping through code wanting to check the value of a field. Unfortunately, I don’t know the field’s name-it could be Name, UserName, NameUser, txtName, and so on. It’s a… Read More »

cIniFile

Complete access to INI files through a simple class module, which works with VB4 16,32 and VB5. This class module allows you to read/write INI values, delete values, delete sections and query whole sections through a simple inteface. Original Author: Steve McMahon Inputs Here is a sample of using the cIniFile class:dim cIni as new cIniFilewith cIni.Path = “C:WINDOWSSYSTEM.INI”… Read More »

Create database user

The following function creates a user. You can execute it under any user you like.dror-a@euronet.co.il (Dror Dotan A’) Original Author: Newsgroup Posting API Declarations const ADMIN_USERNAME = “Admin”const ADMIN_PASSWORD = “adminpass (or whatever)”const SHOWICON_STOP = 16 Code Function CreateNewUser% (ByVal username$, ByVal password$, ByVal PID$)  ‘- create a new user.  ‘- username$ – name  ‘- password$ – user password  ‘- PID$ – PID… Read More »

.INI read/write routines

.INI read/write routinesmfncGetFromIni– Reads from an *.INI file strFileName (full path & file name)mfncWriteIni–Writes to an *.INI file called strFileName (full path & file name)sitush@aol.com Original Author: Newsgroup Posting Returns mfncGetFromIni–The string stored in [strSectionHeader], line beginning strVariableNamemfncWriteIni–Integer indicating failure (0) or success (other) to write API Declarations Declare Function GetPrivateProfileString Lib “Kernel” (ByVallpApplicationName As String, lpKeyName As Any,… Read More »

NetworkRoutines

NetworkRoutines:DisconnectNetworkDrive, MapNetworkDrive,GetUserName,GetUNCPath,etc.proactiv@ssnet.com (Kenneth L. Rosenberg) Original Author: Newsgroup Posting API Declarations Private Declare Function WNetAddConnection Lib “mpr.dll” Alias“WNetAddConnectionA” (ByVal lpszNetPath As String, ByVal lpszPasswordAs String, ByVal lpszLocalName As String) As LongPrivate Declare Function WNetGetConnection Lib “mpr.dll” Alias“WNetGetConnectionA” (ByVal lpszLocalName As String, ByVallpszRemoteName As String, cbRemoteName As Long) As LongPrivate Declare Function WNetCancelConnection Lib “mpr.dll” Alias“WNetCancelConnectionA” (ByVal lpszName As String,… Read More »

ACCESS BACKUP ROUTINE

A short routine that backups the tables from an open Access databaseGeorge Kinney Original Author: Newsgroup Posting Assumptions Right now it is basic, it assumes that the tables to backup are in the local database (easily changed, just haven’t had a chance to do it.), and just exports EVERYTHING that isn’t filtered out. A number of improvements can (and… Read More »

Copy a database table

How to copy a database table. This may require some tweaking….“Bill Pearson” Original Author: Newsgroup Posting Code Private Sub Form_Load()    Dim dbFrom As Database  Dim dbTo  As Database    Set dbFrom = workspaces(0).opendatabase(“c:vb4iblio.mdb”)  Set dbTo = workspaces(0).opendatabase(“c:vb4iblio.mdb”)    db_Copy_Tabledef dbFrom, dbTo, “Authors”, “CopyOfAuthors”    dbFrom.Close  dbTo.Close  End SubPublic Function db_Copy_Tabledef(dbFrom As Database, dbTo As Database,TableNameFrom As String, TableNameTo As String) As Boolean    Dim tdFrom    As TableDef  Dim tdTo     As TableDef  Dim fldFrom   As Field  Dim fldTo    As… Read More »