Results for "Author: james vincent carnicelli"
Here's a VB programmer's introduction to developing Internet (TCP/IP) applications. We'll build a trivial web browser to start with Then we'll look at some of the issues you should consider when building client/server applications. We'll even build a simple one.
The XML Engine is a set of classes designed to make it easy for your programs to parse and construct XML. The parser can be used either to automatically construct an easy-to-use data structure (like I.E.'s document object model) or direct your program (through events) to do what it needs to on the fly. This latter mode facilitates work on the data even as the XML is being incrementally received, as from a long file download. This means your program won't have to wait to start work and can avoid memory overruns associated with "passively" parsing huge XML files. This approach could even be used with an endless stream of XML, which would be great for quickly implementing a simple client/server communication protocol (search for my "Socket Controls" package here at PSC). The XmlElement class, which represents a node in an XML tree, can be used independently of the engine. Your program can easily clone an XML tree, insert new branches anywhere, remove whole branches, and export it to raw XML or plain text (stripped of XML tags). The plain-text export can be given an array telling it what to replace certain tags with, too. An element node can be either a representation of a named tag (e.g., "TABLE") with named attributes or a text block (anything that would appear in-between tags). A demo program is included with simple demonstrations of a number of basic techniques. This engine does not deal with every last idiosyncracy of XML and assumes any XML it parses is well-formed. DTD's are not supported (not that they really relevant, here). But the basics of XML are supported. It can even be used as an HTML generator and parser, provided the HTML is XML-formatted (all start tags must have end tags or be single-tag formatted like "<SOMETAG/>"). Unfortunately, there is currently no documentation, but the code is straightforward and easy to read. Further, the demos should provide enough explanation for how to use the engine. Your comments and votes are welcome.
This article introduces you to the basic concepts behind Visual Basic's run-time error handling methodology. You'll learn what causes run-time errors, how to deal with them, and how to generate them yourself. A good understanding of run-time errors is critical to becoming a seasoned VB programmer. Arm yourself now.
This is an old utility I made a few years ago in VB 5. It can display the main project files in a .VBP and display the contents and a summary of what's in its code modules, color-coded. It was designed to let any VB project be a reference for itself. To that end, it picks out any comments that appear immediately before a subroutine or function. And since its output is a RichEdit control, you can copy and paste anything it outputs into Word or some other editor for instant documentation. While it's probably lacking a few reserved keywords and might be a little out of date, it's got a valuable core of logic to parse VB code and an algorithm to color-code VB stuff for a RichEdit control. I welcome comments and improvements, so long as you give credit where it's due. Please vote for this code if you find it useful.
VB (version 6 and earlier) doesn't offer any decent way to create a new class that inherits public members from an existing one. Here's an easy, if inelegant, way to simulate inheritance.
How to keep your VB application from being a CPU hog using DoEvents.
Conceptually, non-volatile RAM is any RAM (random access memory) that is not lost because the memory device loses (external) power. The NvRam class implements this in a primitive but powerful way: by writing to and reading from a data file in real time. In principle, your code need only identify the location in this "memory" (as in an array) that a given variable is stored in and the class does the rest. Here's a simple example of how it works: Dim MyVar As Long Set Nvr = New NvRam Nvr.Connect "C:\MyData.dat" 'Read in value, 'do something with it, 'and write it back out. Nvr.ReadVar MyVar, 20 MyVar = MyVar + 1 Nvr.WriteVar MyVar, 20 Nvr.Disconnect Here are some good applications for this class: - Protecting in-"memory" data from power failures. - Maintaining large amounts of data with almost no memory overhead. - Maintaining program state across run-time sessions. - Sharing data among multiple processes. While it does not yet have built-in support for storing user-defined data types or objects, all primitive data types (e.g., Long and String) are supported. (Variants are allowed, so long as they are late-bound to one of the primitive data types.) Also missing is a way to shrink the size of the data file, the equivalent of ReDim Preserve. Feel free to make suggestions or add support for such features, so long as credit is given for the original code. While tested with VB6/NT4, this should be compatible with any version of Windows that supports the CopyMemory() API call and which has data types with the same sizes as with Win32 systems like NT. Your comments and vote are welcome.
Simple ways to create data structures on the fly without creating classes, user-defined types, etc., and how such structures can be more flexible, data-driven, and even self-defining.
Nifty little utility (with source project) to help you use Windows system colors (e.g., "Button Face" or "Window Text") in your code. For each color, shows a preview, the name you see in IDE property window's drop-down list for colors, the VB constant, and the hex value. Tiny, easy to use, and fast. Please vote for this entry if you like it.
This utility allows you to create a keyboard script which, when played, sends keyboard events to your target application as though a human user had. This is a great way to deal with batch processing of tasks that you know are repetitive. It can also be used for scripting demonstrations. In addition to just sending key combinations, the macro language allows you to pause for user intervention, wait for a number of seconds or milliseconds, insert helpful comments, and so on. Think of it as application integration scripting. To make your job easier, you can call up an active "cheat sheet" with all the codes for oddball keys like backspace or print-screen. The program includes a simple but complete (plain text) help file. And you can save and later reload load your scripts, too. Your comments are welcome. And if you like this utility, please vote for it. Thanks. ---------------------------------------- Recent Updates: - 11/13/2000: Fixed minor bug; added features to "cheat sheet"
Want anyone with a common web browser to be able to upload files to your ASP application? Here's a great little component to help you do it. This component builds on the standard mechanism web browsers provide for uploading files. Since IIS doesn't provide any simple built-in way to deal with this, this component fills the void. Here's how simple your ASP code can be: Set Upload = Server.CreateObject("Carnicelli.FileUpload") Upload.Save "C:\Temp" Response.Write "<LI>" & Upload.Form("Email") Response.Write "<LI>" & Upload.File(1).FileName I crammed a number of useful features for manipulating the resulting files, generating unique file names, and more. This code teaches many programming lessons. It demonstrates MIME processing, array and string manipulation (includes powerful array and string manipulation libraries), generating unique file names, real-time stream processing, interfacing with IIS' built-in objects (e.g., "Request" and "Session") without help from the ASP code, binary file manipulation, processing with a finite-state-machine model, MTX (Transaction Server) components, and more. Please comment on this code and vote for my hard work if you like this code. -------------------------------------------------- Now there's a commercial version of this product available. It's been rebuilt from the ground up, correcting all the issues you've reported here and including new features. And it comes complete with extensive documentation and good service. Check it out!
I use arrays all the time, so I thought I'd put the functions I commonly use together into a library. Easy to read code. Routines include: - ArrayCopy(List, ListToCopyFrom, [StartAt], [Length]) - ArrayAppend(List, Item) - ArrayRemove(List, Index) - ArrayInsert(List, Index, Item) - ArrayConcatenate(List, ListToCopyFrom) - ArrayTrim(List, [TrimFromBeginning], [TrimFromEnd]) - ArraySplice(List, StartAt, Length, [ListToCopy]) - ArrayToString(List, [Separator]) Clean code with lots of comments in reusable module. Also includes an extensive reference in HTML. Tested with VB6, but should be compatible with all modern versions and VBScript (with minor modifications). Please vote for this code if you like it.
Library of routines for typical string processing, including parsing, translation, and validation. Routines include: - StrReplace(Text, SearchFor, ReplaceWith, [Compare]) As String - StrSplit(Text, SplitOn, [Compare]) As Variant - FromHex(HexNumber) As Long - LeftPad(Value, Size, [PadCharacter]) As String - RightPad(Value, Size, [PadCharacter]) As String - AreLetters(Text) As Boolean - AreDigits(Text) As Boolean - AreLettersOrDigits(Text) As Boolean - AreInSet(Text, CharacterSet, [CaseSensitive]) As Boolean - ParseN(Text, StartAt, PatternArray, ValueArray, [PosPastEnd], [StopAt], [Compare]) As Boolean Clean code with lots of comments in reusable module. Also includes an extensive reference in HTML. Tested with VB6, but should be compatible with all modern versions and VBScript (with minor modifications). Please vote for this code if you like it.
Data entry control for U.S. postal addresses in a single text box with automatic parsing and assembly. If your application has to allow users to enter and view snail-mail U.S. postal addresses, your usual choices are separate text boxes for the parts of the address or one big text box for the whole thing. Usually, which it is depends on how you store it. This control gives your users the ease of having a single text box and your program the power to pick out the two street address lines, city, state, zip code, and 4-digit zip code extension as separate parts. Does format validation, state abbreviation validation, state name conversion to abbreviations, data parsing and assembly to and from the same plain-text representation seen by users. Provides simple explanations for why a given address is invalid, if so. Also provides many of the most commonly-used properties and events of a typical text box. As easy to use in your project as an ordinary text box. Extensive documentation provided in the code. Also includes an extensive HTML help file and demo project. Recent Updates: 5/18/2000: Added .Populate() method 5/22/2000: Vastly improved parser to accommodate odd an incomplete addresses and added public array of error codes / messages. Please vote for this code if you like it.
I created this because I needed to be able to adjust how many child processes my batch processing app created so that it didn't I created this demo because I needed to be able to adjust how many child processes my batch processing app created so that it didn't overutilize the CPU. To duplicate this, create a form with one text box (Text1) and one timer (Timer1) in the configuration you see in the screen shot. Then paste the code seen here. The main key is the windows idle process (PID = 0), which eats up whatever CPU cycles are not used by other apps. Every so often, this code takes a sample of how much CPU time, in seconds, that process has taken up since it started. Then it takes the delta to calculate its own CPU utilization. Subtract it from 100% and you get the CPU utlization. In this case, we're using the Windows Management Interface (WMI) to get this information -- mainly because the API calls to get process times won't work for the idle process for security reasons. This should work for Windows 2000 and XP, but probably not for NT 4.0- or Windows 3.x, 9x, or ME. You can morph this sample a lot of ways. For example, increase the SampleRate variable to get a smoother variation curve over time or decrease to get more immediate values. You can use additional parameters in Locator.ConnectServer() to connect to a remote machine, as another example. See here for more about the WMI objects: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_reference.asp You could also easily modify this to track some other process' CPU utilization by its PID. Or you could also use it to track memory or other resource utilization. - Cheers, Jim Carnicelli
PKZIP, ARJ, ARC, JPEG, and a host of other programs and compressed file formats all use the Huffman coding algorithm (or similar redundancy-minimization methods) for compressing strings. With this small VB module, you can do your own compression in code -- compressing strings down to as small as 13%. Here's how easy it is: Compressed = HuffmanEncode(Text1) Text2 = HuffmanDecode(Compressed) This simple code can be used to compress big text fields in databases, keep your data files small, or speed up transfers of data across the Internet. It can also be used as a form of encryption. The HuffmanCoding.bas module has plenty of extra information and some in-code documentation (in case you're wondering out how it works.) Please comment on this code and vote for my hard work if you like this code. _____________________________________ Updates: 1 August 2000: Rebuilt from scratch Compression takes 28% of the time it did before Decompression takes 19% of the time it did before There's only one file, now (no extra class) Much better error checking and reporting Uses a stored checksum upon decompression to check for corruption The code is only 455 lines, including comments! Thanks to optimization, the code is even more convoluted :-)
Want anyone with a common web browser to be able to upload files to your ASP application? Here's a great little component to help you do it. This component builds on the standard mechanism web browsers provide for uploading files. Since IIS doesn't provide any simple built-in way to deal with this, this component fills the void. Here's how simple your ASP code can be: Set Upload = Server.CreateObject("Carnicelli.FileUpload") Upload.Save "C:\Temp" Response.Write "<LI>" & Upload.Form("Email") Response.Write "<LI>" & Upload.File(1).FileName I crammed a number of useful features for manipulating the resulting files, generating unique file names, and more. This code teaches many programming lessons. It demonstrates MIME processing, array and string manipulation (includes powerful array and string manipulation libraries), generating unique file names, real-time stream processing, interfacing with IIS' built-in objects (e.g., "Request" and "Session") without help from the ASP code, binary file manipulation, processing with a finite-state-machine model, MTX (Transaction Server) components, and more. Please comment on this code and vote for my hard work if you like this code. -------------------------------------------------- Now there's a commercial version of this product available. It's been rebuilt from the ground up, correcting all the issues you've reported here and including new features. And it comes complete with extensive documentation and good service. Check it out!
This utility allows you to create a keyboard script which, when played, sends keyboard events to your target application as though a human user had. This is a great way to deal with batch processing of tasks that you know are repetitive. It can also be used for scripting demonstrations. In addition to just sending key combinations, the macro language allows you to pause for user intervention, wait for a number of seconds or milliseconds, insert helpful comments, and so on. Think of it as application integration scripting. To make your job easier, you can call up an active "cheat sheet" with all the codes for oddball keys like backspace or print-screen. The program includes a simple but complete (plain text) help file. And you can save and later reload load your scripts, too. Your comments are welcome. And if you like this utility, please vote for it. Thanks. ---------------------------------------- Recent Updates: - 11/13/2000: Fixed minor bug; added features to "cheat sheet"
Read an entire text file into a string in one call.
Data entry control for U.S. postal addresses in a single text box with automatic parsing and assembly. If your application has to allow users to enter and view snail-mail U.S. postal addresses, your usual choices are separate text boxes for the parts of the address or one big text box for the whole thing. Usually, which it is depends on how you store it. This control gives your users the ease of having a single text box and your program the power to pick out the two street address lines, city, state, zip code, and 4-digit zip code extension as separate parts. Does format validation, state abbreviation validation, state name conversion to abbreviations, data parsing and assembly to and from the same plain-text representation seen by users. Provides simple explanations for why a given address is invalid, if so. Also provides many of the most commonly-used properties and events of a typical text box. As easy to use in your project as an ordinary text box. Extensive documentation provided in the code. Also includes an extensive HTML help file and demo project. Recent Updates: 5/18/2000: Added .Populate() method 5/22/2000: Vastly improved parser to accommodate odd an incomplete addresses and added public array of error codes / messages. Please vote for this code if you like it.