Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all 1467 articles
Browse latest View live

Word extractor program.

$
0
0
Hi all
This is my vague program to extract the words that are used in a text with no repetition.
It does the purpose for me at this level. I liked to share with you hoping someone have the time to add some more functions.
thank you.
Attached Files

AutoComplete (Using the IAutoComplete interface)

$
0
0
This project is intended to demonstrate how to implement the IAutoComplete interface to VB6.

It provides more features than the "SHAutoComplete" API.

For example to determine whether the drop-down list is dropped down or not.
But the most important feature is that you can define custom sources. (by a simple string array)

At design time (IDE) there is only one dependency. (AutoCompleteGuids.tlb)
But for the compiled .exe there are no dependencies, because the .tlb gets then compiled into the executable.

Notes:
- There is no way to uninitialize the autocomplete object. You can only disable it. Setting the autocomplete object to nothing has therefore no effect and is not recommended. Anyhow, the autocomplete object will be automatically uninitialized when the TextBox (or any other edit control) receives the WM_DESTROY message.
- Use modeless forms to enable the user to use the mouse on the drop-down suggest list as else only keyboard inputs will work on modal forms.

List of revisions:
Code:

13-Aug-2013
- Fixed a bug that the application will crash when there is an empty string in the custom source.
12-Aug-2013
- First release.

Attached Files

Pinboard (plus bonus - 100 free pushpins!)

$
0
0
This project was made per a request by a member who needed an application that user could load an image and push pins into it and have a descriptive label for the pins.
Attached Files

VB6 - ThinDavApi, Cloud Storage for the Masses

$
0
0
ThinDavApi

ThinDavApi is a small DAV client API based on MSXML.

Its main limitations are:

  • No support for DAV resource locking.
  • No partial-resource reading or writing, it deals with whole resources.
  • No chunked transfer support, so it is better suited for smaller resources or situations where your application can afford the memory to hold a medium sized resource in memory.
  • Only supports a few common resource properties, does not support modifying properties of existing resources.


ThinDavApi refers to resources as "files" and collection resources as "directories" but this is merely an abstraction since they are really BLOBs of data. ThinDavApi can read/write binary data or UTF-8 text, handling text translation to and from Windows Unicode (UTF-16LE) via MSXML's facilities.


Purpose

ThinDavApi is meant to offer programmers a simple way to implement "cloud storage" within applications. There are many inexpensive and even free WebDAV hosting services you might use for a number of purposes. Examples might include submitting and/or retrieving updated data, remote logging, error reporting, and contact requests. This allows you to completely replace the use of SMTP email or FTP, both of which can suffer from insecure data transfer and firewall or ISP blocking problems. Very few firewalls will block WebDAV traffic over standard HTTP (port 80) or HTTPS (port 443).

ThinDavApi does not require any "web folder" setup and doesn't use any of the Microsoft WebDAV filesystem redirectors. When used with MSXML 3.0 which is perfectly adequate ThinDavApi can work on any version of Windows as far back as Windows 95. On an older OS you'd need to deploy MSXML 3.0 unless it was already installed by another product (e.g. IE 5.x). It is installed on every OS from a fully patched Win2k SP4 installation on up and is patched with bug fixes via Windows Update.

Some limited testing has been done using MSXML 6.0 but considering its deployment issues any advantages it offers probably don't warrant its use. However there might be a small performance boost in doing so as long as you only target systems where MSXML 6.0 is preinstalled or you are willing to deploy it (Win2K SP4 through WinXP SP2).


Aync Operation

Since the main reason for your programs to use WebDAV is to access a remote datastore over the Internet, synchronous operations aren't really practical. Because of this ThinDavApi does not support them.

All requests you make through ThinDavApi calls end by raising a Complete event. You can determine success or failure and retrieve results in your event handler.

Timeouts should be handled in your program using a timer of some kind. When a request takes too long you can call AbortRequest, and when Complete is subsequently raised you can test for the Aborted property.


Thin Wrapper

DAV is an XML-based protocol on top of HTTP.

ThinDavApi is a fairly thin wrapper on the MSXML library. Because of this request completion status information is reported as HTTP results (status code and status text) and some requests provide HTTP response headers after minimal parsing.

You don't need any XML knowledge to use ThinDavApi unless you need to do some advanced debugging or to add or modify features of ThinDavApi. Your best reference on DAV is probably RFC 2518, which covers all of the things ThinDavApi supports (and more).


Supported Resource Properties

ThinDavApi will make a PROPFIND request through its GetDir() method which returns:

  • Name - simple name of a file or directory. String.
  • FullName - fully qualified path of a file or directory below the ThinDavApi BaseURL property. String.
  • LastModified - timestamp. Date.
  • ContentType - MIME type (only files). String.
  • Length - in bytes at the server (only files). Long.
  • IsFile - False for a directory and True for a file. Boolean.


The returned XML is parsed into a Variant property DirEntries. DirEntries is an array of Variant arrays, one row for the file or directory queried on and one row for each "child" resource unless the call specifies ChildInfo = False. Each column in these inner "DirEntry" arrays corresponds to one of the supported properties, translated to an appropriate Automation type (e.g. Date, Long, Boolean, or String in VB terms).

ThinDavApi also accepts an optional ContentType to use when creating a file by calling PutFileBytes() or PutFileText(), or if none is supplied a default is used.


Source Code, Usage

The ThinDavApi.cls module contains a block of comments describing its properties, methods, and events.

It has been provided here as part of a demo Project "ThinDAVMan" which makes use of most of its supported operations. In particular I've tried to show how to handle the async method calls and implement request timeouts using a Timer control. The ThinDAVMan.zip archive is attached to this post.


From Here

ThinDavApi 1.0 posted here was taken from another WebDAV client class that is at version 3.1, so it has had a lot of testing and debugging done already. However it may still have flaws including some that won't show up until somebody tries to use it with some server I haven't used yet. Despite the WebDAV standard I have found variations out there which required subtle workarounds.

The goal with ThinDavApi was to make a basic client that can be compiled into a VB6 program or used from VBA. This could also be the basis for a more complete WebDAV client that adds locking and other features, though at that point you may want to look at 3rd party commercial libraries that do a great job.
Attached Files

Push Pin Board

$
0
0
This project was made per a request by a member who needed an application that user could load an image and push pins into it and have a descriptive label for the pins.
Attached Files

VB6 - Test Crypto Functions

$
0
0
As promised, I have attached a VB6 Cryptography Test program originally developed in C++ by:
Michael Jung 2004
Juan Lang 2006
Vijay Kiran Kamuju 2007
The original C++ code is included as TestC++.txt.

Not all functions behave exactly the same as predicted, and much of that I attribute to the fact that Encryption and Decryption routines are done using strings rather than byte arrays. The reason for doing this is that in VB6, data is usually sent and received as string information.

The Test NULL Provider routine has not been implemented at all. Of the first 4 tests that I converted, 3 of them did not behave as predicted. The bulk of the routine seemed to be based on testing for failures rather than productive code, so I abandoned the effort.

I also made no attempt to provide support for XP and older operating systems as the original authors did. There were a lot of system calls that just were not supported by these older systems, and I had no way of testing them.

Most of the system calls have built in error trapping, and would not be present in this format in final working code. But these routines are built as demonstration test code, and a full description of the error is useful. A full list of the 0x80090000 level errors is included in the module.

I am by no means a Cryptographic expert, but I will attempt to address any questions.

J.A. Coutts
Attached Files

Round Colorful Forms

$
0
0
Ok in its raw form this is really quite useless but it contains several interesting parts that can be put to greater use

With this code you can create a round, color changing form that can be moved freely.

Thank you SamOscarBrown for your circle code and Microsoft for helping me get the form movable

you will need a form with a text box and a timer. I named the form frmRound

seeing it work really blew my mind! :eek2:

Code:

Private Declare Function SendMessage Lib "User32" _
                        Alias "SendMessageA" (ByVal hWnd As Long, _
                                              ByVal wMsg As Long, _
                                              ByVal wParam As Long, _
                                              lParam As Any) As Long
Private Declare Sub ReleaseCapture Lib "User32" ()

      Const WM_NCLBUTTONDOWN = &HA1
      Const HTCAPTION = 2

    Option Explicit
    Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function SetWindowRgn Lib "User32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
 

   
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _
                                X As Single, Y As Single)
        Dim lngReturnValue As Long

        If Button = 1 Then
            Call ReleaseCapture
            lngReturnValue = SendMessage(frmRound.hWnd, WM_NCLBUTTONDOWN, _
                                        HTCAPTION, 0&)
        End If
      End Sub

    Private Sub Form_DblClick()
      Unload Me
    End Sub
    Private Sub Form_Load()
        Dim lngRegion As Long
        Dim lngReturn As Long
        Dim lngFormWidth As Long
        Dim lngFormHeight As Long
        Me.Width = Me.Height
       
        lngFormWidth = Me.Width / Screen.TwipsPerPixelX
        lngFormHeight = Me.Height / Screen.TwipsPerPixelY
        lngRegion = CreateEllipticRgn(0, 0, lngFormWidth, lngFormHeight)
        lngReturn = SetWindowRgn(Me.hWnd, lngRegion, True)
Label1.Left = (Me.Width / 2) - (Label1.Width / 2)
Label1.Top = (Me.Height / 2) - (Label1.Height / 2)
    End Sub
    Private Sub Label1_Click()
      Unload frmRound
    End Sub
    Private Sub Timer1_Timer()
  Static iColor As Integer
  Select Case iColor
  Case 0: Me.BackColor = RGB(255, 0, 0)  ' Red
  Case 1: Me.BackColor = RGB(255, 165, 0) ' Orange
  Case 2: Me.BackColor = RGB(255, 255, 0) ' Yellow
  Case 3: Me.BackColor = RGB(0, 128, 0)  ' Green
  Case 4: Me.BackColor = RGB(0, 0, 255)  ' Blue
  Case 5: Me.BackColor = RGB(128, 0, 128) ' Purple
  End Select
  iColor = iColor + 1
  If iColor > 5 Then iColor = 0
End Sub

VB6 - Jet UserRoster, Connection Control, Backup

$
0
0
Background

When Jet 4.0 came out it offered many new features that go beyond those in Jet 3.x and the Jet 4.0 OLEDB Provider exposes many of them through ADO and a few more through JRO.

Some of these can be useful in getting a Jet database closed so you can back it up, as well as another way to do the backup that runs a compact and repair operation to reclaim space and fix up indexes.


User Roster

It is possible for programs to retrieve a list of active connections open on a database. Since this even shows which computer each connection comes from on a shared database it can be useful in getting persistent opens closed.


Connection Control

A program can invoke Connection Control to prevent new connections to a database from being established. The idea is to get the database closed for backup or other maintenance through attrition, without interfering with existing activity.

Invoke this and put the word out. As connections are closed eventually you can perform the database maintenence once the last man standing... sits.


CompactDatabase

A method of the JRO.JetEngine object you can call to compact an existing database into a new database. Useful as a backup step because it reclaims unused "holes" in the MDB file created by lots of updates and deletes, compacts indexes, and repairs some kinds of internal broken links.


Backup Demo

This demo has two programs:


DbDemo

A small program that opens a database (creating it if necessary) and does some simple queries and updates. It can be run passing a database folder on the command line if you want to test access over the network to a database on a file share.


BackupDemo

A small program that opens the database (creating it if necessary) and sets Jet Connection Control to prevent new connections. Then it polls the database for a list of current users/connections and displays them. Once the connection count is one (just this program) it closes the current database, copies it as a backup, and uses JRO to compact the backup to create a new "current" database.


Running The Demo

Open each Project and compile (Make) it.

Run DbDemo and create a few records.

Name:  sshot0.png
Views: 36
Size:  9.8 KB

Run a second copy of DbDemo.

Run BackupDemo. Observe the users list.

Name:  sshot1.png
Views: 46
Size:  11.3 KB

In the second screenshot there are three connections listed. One of these is an instance of DbDemo running on another computer (ATOMANT in this case). Two more connections show from the first computer (SNITZ), one being a local instance of DbDemo and the other being BackupDemo itself.

All of them show as the user "Admin" since this isn't a secured Jet database. Jet User/Group security is beyond the scope of this writeup.

Close a copy of DbDemo and the list shown in BackupDemo should change to reflect this.

Close the other copy of DbDemo.

Name:  sshot2.png
Views: 32
Size:  10.7 KB

Try starting a new DbDemo copy. It should fail with an error message describing the database's state, which currently blocks attempts to open or lock it.

Name:  sshot4.png
Views: 31
Size:  10.0 KB

When the last DbDemo is gone, BackupDemo should enable its "Back Up MDB" button. Click on this to start the compact & backup process.

Name:  sshot3.png
Views: 36
Size:  18.1 KB

At this point BackupDemo is done. Users can start running DbDemo again, using the compacted database. The original database has been renamed and can be copied off to archival storage as desired.


Remarks

This is a demonstration providing sample code. For a real application you might do things differently, such as creating backup MDB names with timestamps in them. You might create a backup utility with no user interface that can be scheduled to run via Task Scheduler and just "takes off" and does the backup once all other users have closed out.

You might even add some mechanism to send messages from your backup utility to any running copies of the database client application. These could warn the users to finish up and close out for a while, and let them know when the backup is complete.

Don't try to back up directly to a slow network share. It is also best to run your backup utility directly on the box hosting the database. You can't always do this, but it makes the process much quicker and more reliable when possible.
Attached Images
     

[VB6] Application Up Time

$
0
0
The attached Form demonstrates how to retrieve and format for display purposes the amount of time an application (or any process) has been running.


Name:  AppUpTime.png
Views: 29
Size:  2.5 KB
Attached Images
 
Attached Files

[VB6] Clone ListView

$
0
0
The attached project shows how to duplicate the textual contents of another ListView control, even if it's from another process.

Name:  Clone ListView.png
Views: 28
Size:  23.1 KB
Attached Images
 
Attached Files

VB6 - Quizzer: Multiuser LAN Quiz

$
0
0
This project demonstrates that a single VB6 program can be used on several PCs on the same LAN without a separate server program or database in common. This sort of thing is much easier to write and the product is less confusing to maintain if done as two separate client and server programs though.

Pure TCP is used and a UDP discovery technique is implemented so the PCs do not need to be members of the same Workgroup or Domain, no name service is required, and yet no IP addresses need to be entered either.


Preparation

Multiple PCs on a LAN together will need the compiled program installed. You could create a formal installer - the P&D Wizard is good enough. Or an XCopy deployment package could be created using Reg-Free COM tools like the popular MMM ("Make My Manifest") though this requires experience most VB6 programmers don't have.

Nothing stops you from testing by running two copies of Quizzer.exe on your development PC for testing though.

Both MSHFLXGD.OCX and MSWINSCK.OCX (in addition to ADO 2.5, already in Windows) are used by this demo program.


Operation

Some user must play "proctor" and administer the quiz. This person puts his Quizzer.exe into "proctor mode" which opens an extra Form, and from there chooses a quiz file for the quiz to run. After that the proctor starts the quiz and fires each question and then "calls time" when all submitted answers get scored. The proctor can also end the quiz early.

The proctor can also take the quiz himself or just act as an observer/administrator.

Other users won't get the second admin Form, and once someone has taken on the proctor role the "Become Proctor" button will disappear from their quiz Form.

All participants (including the proctor if he chooses to be a participant) must register with a unique name when they first run Quizzer.exe, which they are prompted for. User can leave out this name and just choose to be an observer as well.

Once the proctor has taken charge and picked a quiz he can wait for participants to register. Then he can start the quiz, and begin sending questions. The proctor sends each question, waits the allotted time, and then "calls time" on the question. This scores the submitted answers and reports back to everyone's scoreboard.

Participants wait for questions which are presented along with a multiple-choice list of answers. The pick an answer and click Submit to send their answer to the proctor. Once the proctor calls time, score updates are reported back and the correct answer is pointed out to all particpants and observers.

Once the quiz is finished everyone is left with the scores and rankings to look at until they close Quizzer. The proctor can also optionally save the scores to a CSV file before quitting Quizzer.

Name:  sshot.png
Views: 31
Size:  35.7 KB

Here "Mr. Bill" is acting as proctor. He has just clicked the "Call Time" button,
which has become the "Next Question" button.


Just A Demo

Quizzer isn't perfect.

There are many features that might be added. There may be some features that are not needed that could be ripped out.

The question file format is a bit rough (see the comments in Globals.InitProctor). This discovery protocol's UDP port is hard-coded (see Globals.PROCTOR_UDP_PORT). And so on and so on...

And of course there may still be any number of bugs in it yet, as well as plenty of imperfect exception handling. Not everything has been thoroughly tested.


How Quizzer Works

Without going into detail (though I'll admit the code itself can be rough to follow)...

There are two Forms, one called MainForm and the other ProctorForm.

MainForm is basically a user interface for displaying the scoreboard, displaying questions, and accepting answers.

ProctorForm is a sort of "reverse TCP server." It tracks everything, runs the quiz, maintains the "database" in memory using a pair of ADO Recordsets, and manages TCP connections to all of the MainForm instances on the LAN.

ADO Stream objects are heavily used for serializing and deserializing messages sent both ways over the TCP connections.

Discovery is accomplished by having each MainForm send UDP broadcasts out to the LAN containing the registration name of the user, his IP address, and the TCP port he is listening on. Once there is a ProctorForm running and it sees such a broadcast database entries are made and then ProctorForm connects back to the remote MainForm. When MainForm gets the connection established it stops broadcasting its announcements and is ready for the quiz to begin.

Large amounts of code and data used by both Forms is kept in Globals.bas in an attempt to make the code in the two Forms a little less cluttered.

There are also two other Forms: RegisterDlg and ProctorDlg. These are used as simple dialogs for getting information before carrying on with the business of the bigger Forms.
Attached Images
 
Attached Files

Converting amount in words to figures in excel

$
0
0
Dear Friends,

Can anyone help me on converting amount in words to figures in excel 2007.
(Ex: Twenty thousand three hundred and fifty - 20,350.00)

SizeGrip Control

$
0
0
This is a UserControl for simulating a SizeGrip.

It is only drawn themed when the app is linking to version 6.0 (or higher) of the comctl32.dll.
The SizeGrip is hidden when the form is maximized.

Name:  SizeGripSamplePic.png
Views: 27
Size:  7.1 KB

Attachment: Sample project with the sizegrip (user)control.
Attached Images
 
Attached Files

VB6 (ActiveX-Exes and selfhosted Threading)

$
0
0
Here's an example for a simple AX-Exe-Threaded-Selfhosting-approach (calculating a Mandelbrot-Set on two worker-threads -
reflecting the results "row-by-row" in the GUI-MainThread then per normal cross-thread-COM-events).
http://vbRichClient.com/Downloads/MBSetAxThreaded.zip (<-- this zip contains also the compiled executable - whilst the other download at the bottom contains only the sources)

Would really like to see a .NET-version which does the same thing in the same performance (just try in the compiled Executable, and not in the IDE for "full-threaded-speed").
(the VB6-code is a bit rusty, it's already a few years old - but still working as it seems - just put it here as a reference).



Olaf
Attached Images
 
Attached Files

VB6 3D-Surface-Plotting (based on RichClient5)

$
0
0
Just another Demo, which applies antialiased and semitransparent Drawing-commands in a somewhat similar way as the "Bezier-Art"-Demo here:
http://www.vbforums.com/showthread.p...ezier-Art-quot

But in a perhaps more useful (or practical) fashion...

The implementation allows for a few nice things as rotation around the Z-axis (Azimuth) - as well as changing the Altitude per Mouse (the height above the x-y-plane).
There's a few predefined Formulas in the appropriate Combo-Box, but you can type in your own stuff as well.
To support symmetrical Surfaces as e.g. spheres or "donuts", the Plotter allows also the formula: z² = f(x,y) (as an alternative to the usual z = f(x,y)).

But here's a few screen-shots which are far more telling I assume:




This is the wellknown "saddle":




And this is the same saddle-plot. but now with an altitude of 90 degrees (full Top-View):




Here a few more shots, but only as "normal links", to not clutter the posting with too many images:
http://vbRichClient.com/Downloads/3dSrfPlot1.jpg
http://vbRichClient.com/Downloads/3dSrfPlot4.jpg
http://vbRichClient.com/Downloads/3dSrfPlot5.jpg
http://vbRichClient.com/Downloads/3dSrfPlot6.jpg

Ok, finally the Source-code-link (as said, dependent on the RC5-libs which one can download from vbRichClient.com):
(only 7KB, so it's a pretty small code-base to study).

Have fun with it.

Olaf
Attached Files

VB6 - RicherLabel UserControl

$
0
0
Sometimes you need to use one or more Labels on a Form that just need to offer a little bit "richer" options.

Maybe you need to have some of the text bold or underlined. Maybe you need a superscript or subscript. Maybe you need to use a symbol from one of the symbol fonts like Windings. Maybe you need a second color to highlight a word or a symbol.

RicherLabel offers a way to do this without a lot of trouble. It basically accepts a Caption property with a simple markup syntax and renders the Caption according to the markup instructions.

You can even do simple "color blinking" as shown in the demo.

Some limitations:

  • It doesn't support a BorderStyle.
  • No multiline support.
  • No word-wrap.
  • No justification (always left-justified).


If you need some with a border and some without, make another copy of the UserControl and name it something like RicherLabelB and then set the UserControl's BorderStyle. Or you might rework RicherLabel to draw its own border and add a BorderStyle property to it.

You could also work out a scheme for it and then implement word-wrap and multiline labels.

The RicherLabel markup consists of instructions of one character escaped using the ` (accent grave) character. You could easily change this yourself to something else, or maybe change the way the color table works, etc. You can also strip out functions you don't need pretty easily to reduce the compiled size of programs using RicherLabels.

Name:  sshot1.png
Views: 39
Size:  8.9 KB

Demo: Design Time


Name:  sshot2.png
Views: 49
Size:  16.7 KB

Demo: Run Time
Attached Images
  
Attached Files

VB6 Simple Async-Download-Ctl for multiple Files

$
0
0
Just a simple demonstration of the AsyncDownload-Feature, any VB-Usercontrol has already built-in.

It supports http- and ftp-downloads for files up to 2GB.

What's perhaps interesting from a Control-Design-point, is the organization of the whole thing.

There's a Host-Control: ucAsyncDLHost which only ensures Scrolling and Event-Delegation of the
separate Download-Entries it manages and visualizes.

The AsyncDownload itself is performed within another (Child-)Control: ucAsyncDLStripe,
which is a windowless-Control (containing a simple Progress-Bar and a simple Stop/Resume-Button).

So, those windowless-"Stripe-entries" make up the "Rows" within the outer ucAsyncDLHost Control.

Here's the usual Screenshot and the Download-Link:

http://vbRichClient.com/Downloads/As...nloadDemo2.zip

Olaf
Attached Images
 

VB6 - JsonBag, Another JSON Parser/Generator

$
0
0
With SOAP basically a dead duck and XML itself fading in importance, JSON is becoming more and more important as a serialization format today.

I've seen a number of VB6 JSON implementations around, including a couple posted right here in the CodeBank. Sadly none of them are very good, with little quirks and latent bugs (like improperly handling numeric data). Most of these ignore and flout the JSON standards at JSON too!

In any case I have my own implementation designed to conform as closely as possible to the standard, and now at version 1.6 it seems mature enough to share. I rewrote my notes into six pages of documentation which should make it a bit easier for others to use.


Bug reports are welcome. Though it seems to be working fine it is hard to prove code to be correct and there are probably edge cases I've never encountered.

Performance seems more than adequate for its purpose, which is mainly access to cloud computing services. Local config files are probably best still handled as plain old INI format files, though one could use JSON for that as well I suppose.


There is just one Class involved: JsonBag.cls, and as the documentation suggests it should be easy enough to import into a VBA host (Excel, etc.) as long as you tweak the API calls for 64-bit hosts when required.


The attachment includes this Class along with the documentation in RTF format, packaged up as a testbed Project JsonBagTest.vbp:

Name:  sshot.png
Views: 246
Size:  20.5 KB

As you can see JsonBag supports a Whitespace property to format JSON for readability. By default compact JSON is generated.


Accessing the "document model" and creating JSON documents in code is easy enough. This is illustrated by a fragment from the test Project:

Code:

Private Sub cmdGenSerialize_Click()
    With JB
        .Clear
        .IsArray = False 'Actually the default after Clear.

        ![First] = 1
        ![Second] = Null
        With .AddNewArray("Third")
            .Item = "These"
            .Item = "Add"
            .Item = "One"
            .Item = "After"
            .Item = "The"
            .Item = "Next"
            .Item(1) = "*These*" 'Should overwrite 1st Item, without moving it.

            'Add a JSON "object" to this "array" (thus no name supplied):
            With .AddNewObject()
                .Item("A") = True
                !B = False
                !C = 3.14E+16
            End With
        End With
        With .AddNewObject("Fourth")
            .Item("Force Case") = 1 'Use quoted String form to force case of names.
            .Item("force Case") = 2
            .Item("force case") = 3

            'This syntax can be risky with case-sensitive JSON since the text is
            'treated like any other VB identifier, i.e. if such a symbol ("Force"
            'or "Case" here) is already defined in the language (VB) or in your
            'code the casing of that symbol will be enforced by the IDE:

            ![Force Case] = 666 'Should overwrite matching-case named item, which
                                'also moves it to the end.
            'Safer:
            .Item("Force Case") = 666
        End With
        'Can also use implied (default) property:
        JB("Fifth") = Null

        txtSerialized.Text = .JSON
    End With
End Sub

Attached Images
 
Attached Files

Fuzzy Search Demo [VB6/vbRichClient5]

$
0
0
The vbRichClient5 library for VB6 includes support for the SQLite database engine, and acts as a wrapper for the user defined collation (sort) and user-defined functions features of SQLite. Thanks to the work of Olaf Schmidt, it is really easy to create standard VB6 classes that extend the functionality of SQLite.

I've been experimenting with some "fuzzy" search routines using my own custom collation and ranking code (modified Metaphone), intertwined with the vbRC5 ranking code (RatCliff), and have put together a little demo here:

RC5SearchDemo.zip

Before you can use this demo, you will need to download and register the vbRichClient5 library from http://www.vbrichclient.com/#/en/Downloads.htm

"Search" is a really interesting (and constantly evolving) area of human>computer interaction, and I think VB6 is somewhat lacking (no native regex, no built-in fuzzy algorithms like metaphone, ratcliff, etc...). I'm really hoping for some input from the community on how to make this fuzzy matching better, under more search/language scenarios - for the benefit of all. Please feel free to hack away with the above demo and report back with your results, and let's see if we can create a search algorithm (or suite of algorithms) that produce consistently useful results.
Attached Files

DNS Filter

$
0
0
Our DNS server was being used as an attack vector against primarily Chinese servers. DNS by preference uses UDP packets instead of TCP packets. The UDP protocol is much faster than TCP, but unlike TCP it does not perform a handshake. It is essentially one way communication with no confirmation of receipt. Because of that, it is possible to fake the sender IP address, and this is what the attackers were doing. A 128 byte request was causing a 388 byte invalid response to be sent to the target server. By enlisting many hacked computers, the attackers could overwhelm the target. Because the hackers were sending false source information to legitimate DNS servers, it was difficult to track the actual source.

Our DNS server has the capability to block source addresses that send too many requests per second, but it was getting to be a pain to update the list, and the list itself was getting quite long. So I set about to design a filter. For this purpose I am using the Windows Packet Filter Kit from NT Kernel Resources. This high performance packet filtering framework hooks the NDIS (Network Driver Interface Specification) driver in your Windows Operating System. This allows me to inspect each packet and only target incoming Port 53 UDP packets for further processing. A 20 element cache is maintained with the Source IP Address, the Question Type, the Question, and a Timeout. When a DNS request is received, the program checks the cache and if does not exist or is timed out, it is added with the maximun timeout. If it already exists, the timeout is reset to the maximum and the record dropped. A timer decrements the timeout values every second.

I had considered building this progam some time ago because some abusive DNS servers were using brute force by sending multiple requests for the same thing. The worst offender was Yahoo, which not only sent multiple requests from the same server, but also used multiple servers for the same thing. These hackers only served to elevate the priority.

This program is a work in progress, and once it has proven itself, I will convert it to run as a Service. To run as a Service, I must ensure that the program makes no attempt to display to the Desktop, as this can cause the operating system to get into an endless loop when the user is logged off and the desktop is not available. All potential errors must be trapped, and logged to the Event or other log.

J.A. Coutts
Edit: When the filter was put into production, a bug was discovered that caused Overflow errors in the PacketRead routine. The problem was caused by Message Types greater than 32,767, which got interpreted as negative numbers. The problem was resolved by changed the data type to long integer from integer. To facilitate this resolution, Error Trapping and a logging function was added.
Attached Files
Viewing all 1467 articles
Browse latest View live