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

VB6 - Web Service Calls via WinHTTP POST

$
0
0
This is a simple example of using the WinHTTPRequest object to make calls to a simple REST-like web service that processes database queries.

In order to make it a standalone demonstration, the attached archive includes both the client Project and a matching server Project. The server accepts HTTP requests from port 8080 and requires fixed credentials using Basic Authentication. It uses a small Jet 4.0 database as its data store (included).


Requirements

To build and run this demo you will need Windows 2000 SP3, Windows XP SP1, or a later version of Windows. You will also need the VB6 development system, of course.

There are no special CPU, disk, or memory requirements.

Even a network isn't needed, since the client is hard-coded to query "localhost."


Real World

In the real world you would not used fixed credentials. You would not use Basic Authentication over HTTP, opting for more secure authentication or at least forcing the use of HTTPS. Since the embedded web server used here is based on the Winsock control though we don't have the option of using HTTPS here.

This is just a demo.

It is also more likely that your "server" would be a more robust web server hosted remotely. It might be something like Node.JS, or ASP scripts, PHP, etc.

You would also be more likely to use a more compact serialization format than the ADO XML used here. This is convenient in many ways, but you can do better.

One enhancement would be to use ADO's ADTG binary format instead of its XML format, but that is a little tougher for debugging. XML is easier to eyeball.

Another might be to use a more compact XML format of your own invention. More work at both the client and the server but you might radically reduce the response payload size.

Or you might choose an even more compact format such as JSON.


Building and Running the Demo

If TCP port 8080 is already in use you may have to change it in the client Project since it is hard-coded there.

Open the server Project (GossServer.vbp) and do a Make on it. Open the client Project (Client.vbp) and do a make on that.

You can also open both in the VB6 IDE separately and run them from there.

To run the server, which should come first, make sure to keep GossServer.exe, the GossServerVDir folder, and the two database files together so that GossServer can find the other items. You may have to deal with a firewall prompt, but it is fine to allow the firewall to "keep blocking" GossServer.

Once the server is running change the port as needed and click on the Start button.

Name:  GossServer Sshot.png
Views: 98
Size:  31.6 KB

Run the client, set your query criteria, and click the Go button.

Name:  Client Sshot.png
Views: 89
Size:  17.8 KB


Changes

There are lots of possible changes.

You might use a more practical database with multiple tables, relations, views, etc. You might implement adds, deletes, and updates.

The attached archive is big because of the preloaded database files included. There isn't a lot of data there but the .MDW file isn't very compressible.
Attached Images
  
Attached Files

64 bit Integer

$
0
0
There is the odd time that you need a 64 bit integer when interfacing with library files. This is easy to do with C++. You simply create a 64 bit unsigned integer. But VB6 does not offer such as service. The only thing that comes close is a Double Precision number, but there are lots of complications using that. No problem, we will just use 2 long integers (32 bit) to make up a single 64 bit integer. But VB6 only allows us to use 31 bits, as the high order bit is used for negative numbers. Drat! We can however utilize 3 long integers, using 24 bits from the first one, 24 bits from the second, and 16 from the third. The following example demonstrates how the 3 integers can be converted into a single string, as well as how the variable would be incremented. If the variable is to be modified in some other fashion, further logic will be required.

J.A. Coutts
Code:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

    Dim N%
    Dim bTmp(1 To 8) As Byte
    Dim sTmp As String
    Dim TestNum(2) As Long
'    TestNum(0) = 16777215
'    TestNum(1) = 16777215
    Do Until TestNum(2) > 65535
        CopyMemory bTmp(1), TestNum(0), 3
        CopyMemory bTmp(4), TestNum(1), 3
        CopyMemory bTmp(7), TestNum(2), 2
        Debug.Print TestNum(2), TestNum(1), TestNum(0)
        sTmp = StrReverse(StrConv(bTmp, vbUnicode))
        For N% = 1 To Len(sTmp)
            Debug.Print Right$("0" & Hex$(Asc(Mid$(sTmp, N%, 1))), 2) & " ";
        Next N%
        Debug.Print
        If TestNum(0) < 16777215 Then '256 ^ 3 - 1
            TestNum(0) = TestNum(0) + 1
        ElseIf TestNum(1) < 16777215 Then
            TestNum(1) = TestNum(1) + 1
            TestNum(0) = 0
        ElseIf TestNum(2) < 65535 Then '256 ^ 2 - 1
            TestNum(2) = TestNum(2) + 1
            TestNum(1) = 0
        Else
            TestNum(0) = 0
            TestNum(1) = 0
            TestNum(2) = 0
        End If
    Loop

How To Move An Image Using BitBlt

$
0
0
This simple example shows you how to move an image across a canvas using BitBlt API. This example uses a Picturebox control where you move the image using the command buttons or the up, down, left, and right keyboard keys.

The basic steps to move an image are:

1) Save the rectangle area from the Picturebox the size of the rectangle of the original image.

2) BitBlt the original image from it's source to that area on the Picturebox. It is better to use TransparentBlt instead of BitBlt because it does not require that you use masking to make image transparent.

3) Restore the area that was saved

4) Set next position

5) Save the area that represents the next position you want to move the image to

6) BitBlt image to next position

Repeat at Step 3

The attached project use this method.
Attached Files

RPG Game using BitBlt

$
0
0
The filesize of this RPG Game is around 20MB, so I put it here: http://www.udontknowtech.com/rpgGame.zip

Screenshots
Name:  g12ss1.jpg
Views: 91
Size:  307.0 KB

Name:  g12ss2.jpg
Views: 95
Size:  255.8 KB

Name:  g12ss3.jpg
Views: 81
Size:  237.4 KB

Name:  g12ss4.jpg
Views: 87
Size:  260.2 KB

This example uses BitBlt and On-The-Fly Masking so you don't have to mask the character beforehand. It's not perfect, but it's good to learn from. I don't care for criticism but ways to improve are welcome, as I have only done Windows programming and have just recently got into gaming.

The characters were created with "Poser Debut". The 'Shop' icons are from a designer from deviantart.com. The 'Shop' background is one I found online, and so is Lord Bern, except for his eyes, which I had to create in Poser Debut so that he was looking at you, as the original image had him looking down and to the left... which would have been awkward. The music is from "Lord Of Ultima". The sound files are from some random sound pack I got a long time ago. All of the sound files, with the exception of 'walk.wav' are in the resource file (.res). The walk.wav file I couldn't put in the resource file because I needed to call it quickly and repeatedly and I guess it wouldn't load and play that fast because there was just silence, so that's why it's the only .wav file you'll see in the .zip. The map was designed using a map maker I created in VB6 utilizing tiles I found online. The numbers at the top of the Form are x,y coordinates that helped me figure out where to mark some of the objects for collision-detection and so on. Oh... and that dark-looking creature you see in the first and second screenshot is a female troll. She walks and breathes at random intervals randomly bidirectional (east & west).

And many thanks to the members here on VBForums who helped me along the way. You know who you are! Looking forward to learning more and creating something even better.
Attached Images
    

VB6 Simple EMF-based FlexPrint-Reporting (incl. Print-Preview)

$
0
0
Both of the MS FlexGrids which come with VB6 (also the hierarchical one), support the VP_FORMATRANGE command,
and this allows a relative simple interaction with regards to printer- (and multi-page-) related rendering per SendMessage.

So, people who are already familiar with the quite capable Formatting-Options of the (MS-, VideoSoft-, or now ComponentOne-) FlexGrids
can use these Grids as an Object-Model, to build-up simple, nice looking Reports based on a Grid-Layout -
but of course also to just "print out a bunch of Records" over multiple pages.

The Demo is not printing directly to VBs Printer-Object (though this can be done in a second step) - no -
the primary purpose of the relatively small cFlexPrint-Class is, to internally render the Content of a formatted
FlexGrid, into multiple Enhanced-Meta-Files (each EMF-Page of such a multipage-rendering-job will end up as
a serialized ByteArray, stored within a publically reachable VB.Collection (EMFPages As VB.Collection).

This way the generated Report (the Page-Bytearrays within the VB.Collection) could be stored within a DB,
or in the FileSystem, to call-up the Report at a later time (e.g. for a Preview or "Printing it for real").

So, if your reporting-requirements are not all that complex - and when you plan to deploy already one of the FlexGrids
in your App anyways, then this little engine might well be an alternative to larger (not as easy to distribute or "affordable")
Reporting-Engines.

Have fun with it... (and feel free to enhance it on your own, maybe post-back your additions here into the thread)...

Here's the Download-Link: http://vbRichClient.com/Downloads/FlexPrint.zip

And here a ScreenShot (interacting with Tables of NWind.mdb):


Olaf

[VB6] Extract JPEG EXIF Data with WIA 2.0

$
0
0
The attached program is meant to show how to use WIA 2.0 to extract many extended attributes from JPEG photos. It is not a "finished" program but more of a code sample and a testbed for working out the necessary details.

WIA 2.0 ships in Windows Vista and later, and programs that use it will run as far back as Windows XP SP1 as long as you deploy the redistributable version of wiaaut.dll (no longer hosted at Microsoft's download site).

As attached here, the program extracts and decodes many of the more commonly used properties including the embedded thumbnail image.

Those that the program doesn't "know about" are dumped when of a simple type (String, a number type) and described when of a more complex type (Byte array, Integer array, etc.).

A few sample photos are included (thus the large size of the archive) that demonstrate some of the possible items they may contain.


Name:  sshot.png
Views: 106
Size:  57.9 KB
Attached Images
 
Attached Files

VB6 TLSCrypto

$
0
0
SSLClient and SSLServer are companion programs designed to demonstrate Transport Layer Security (TLS) Version 1.0. At the present time, they only support 2 cipher suites:
TLS_RSA_WITH_RC4_128_MD5 (0x00,0x04)
TLS_RSA_WITH_RC4_128_SHA (0x00,0x05)
These 2 suites are supported by virtually all modern browsers and servers, although SHA is more commonly preferred. In addition, 2048 bit asymmetric keys are utilized for the session handshake, since these are strongly recommended by the Internet Engineering Task Force (IETF) since the end of 2013.

In order to support TLS without the use of third party controls or libraries, Microsoft's RSA/SChannel (schannel.dll) is utilized. This library is shipped with all modern Windows Operating Systems. As well, my own cSocket2 Class and accompanying Module (mWinsock2) are utilized. These 2 modules will support IPv6 when it becomes universally available. Although the Cryptography routines will work on most Windows Operating Systems, cSocket2 will only work on systems that support dual stack (IPv4/IPv6). This more or less restricts it to Windows Vista or better.

Originally, I planned on developing only the Client program without Certificates. But the severe lack of detailed information on TLS using SChannel made troubleshooting difficult if not impossible, and I could not connect with remote servers. So I decided to develop a Server program as well. Several months later, I had 2 programs that would communicate with each other, but I still could not communicate with external servers, and online assistance was virtually non-existent. So I then decided to test the server program using my local browser. That meant providing support for Certificates and a whole new level of complexity. But at least the browser provided a little more troubleshooting information than a remote server. This particular project has by far been the most challanging I have ever attempted. The programming itself was not all that difficult, but the lack of information, and the conflict between information that I did manage to find, made it a struggle. Troubleshooting was very difficult because Cryptographers basically strive to eliminate repeatability. Repeatability facilitates hacking.

The included ReadMe file contains the necessary setup instructions.

J.A. Coutts
Attached Files

Accessing MS Access 2003 from VB6

$
0
0
It has been a long time since I wrote any code so please excuse the naming conventions and the novice coding.
In VB6 I have successfully opened an MS Access 2003 database with the following code
Public Sub OpenDatabase()
Dim Msg As String

DbOpened = True
MyFile = App.Path & "\PrintDir.MDB" ' Define name of database.
On Error GoTo OpenDatabase_eh
Set MyWorkspace = Workspaces(0)

' Open database.
Set MyDatabase = MyWorkspace.OpenDatabase(MyFile)
Exit Sub
Later on I successfully update the database with the following code
Public Function UpdateDatabase(strFileName As String)
Dim intErrNbr As Integer
Dim Msg As String
Dim strErr As String
Dim a As Integer
On Error GoTo UpdateDatabase_eh

If strFileName = "" Then
Exit Function
End If
BeginTrans
Set MyTable = MyDatabase.OpenRecordset("FileInfo", dbOpenDynaset)

MyTable.AddNew
MyTable![FileName] = strFileName
.
.
.
MyTable.Update

gstrFileName = ""
glngFileSize = 0
gvarFileDateCreated = ""
gstrFileComments = ""

CommitTrans
MyTable.Close

Exit Function

UpdateDatabase_eh:

intErrNbr = Err
strErr = Error
Msg = "Err = " & intErrNbr & ", Error = " & strErr & vbCrLf & vbCrLf
Msg = Msg & " " & gstrFileName
MsgBox Msg, vbCritical
Rollback
On Error GoTo 0

End Function
However, when I try to delete the table entries, not the table, before I update the table I get error 2075, "The operation requires an open database".
Private Function DeleteTableContents()
Dim strMsg As String
Dim intAns As Integer
Dim DSQL As String
Dim intDCount As Integer
Dim xclSQL As String

On Error GoTo DeleteTableContents_eh
Set MyTable = MyDatabase.OpenRecordset("FileInfo", dbOpenDynaset)
DSQL = "DELETE * FileInfo.FileName FROM FileInfo "
DSQL = DSQL & "WHERE Not FileInfo.FileName = Xtest.jpg" '& "isnull"
'doCmd.SetWarnings False
DoCmd.RunSQL DSQL
'doCmd.SetWarnings True
MyTable.Close
Exit_DeleteTableContents:
Exit Function
DeleteTableContents_eh:
MsgBox "DeleteTableContents - Error Number = " & Err.Number & ", Error Description = " & Err.Description
Resume Exit_DeleteTableContents

End Function


Can anyone see what I am missing?
Thanks

1 or 2 Player Score Four Game + Chat

$
0
0
This is a game of Score Four that you can play against yourself or go online and play your opponent. It also includes a chat window. This VB6 project was written and tested on Windows XP only. I cannot guarantee how it will perform on any other Window's OS.

The zip file contains two folders named Player 1 and Player 2. Only folder Player 1 has the VB project. You need to copy everything from folder Player 1 over to folder Player 2 except the text file named GameInputData.txt. Folder Player 2 already has this file and it is different from the same name file in folder Player 1 so do not copy this file.

Edit the two GameInputData.txt files and put in the information that pertains to you.

The game is folder Player 2 is the one that you will give to your friend.

Open the VB project in folder Player 1 and run it. After it loads right click anywhere on the game board to show the option panel. Select New Game so you can play a game against yourself. To play a two person game open the project in folder Player 2 and run it. On either game click on Connect to Other Player to play a 2-person game.

To play the game left mouse click on any ball you see that is scattered around the front part of the game board. The ball will be highlighted to indicated it has bees selected. Now move your mouse pointer to the top area around any pole and left click. The selected ball will fall down the pole. If you are playing a 1-person game you will see the scattered balls switch colors from one move to another. If you are playing a 2-person game (online with your friend or with yourself using two game boards) the balls do not switch colors but remain on the game. As each ball is selected it is removed showing only the balls remaining to select from.
Attached Images
 
Attached Files

Get The Current Hebrew Date using Visual Basic 6.0 and mscorlib

$
0
0
Most systems have the Microsoft.NET Framework installed. This Visual Basic 6.0 program shows how to call functions from the mscorlib.dll (mscorlib.tlb) from Visual Basic 6.0 to obtain the current Hebrew date.

Code:

' This is a Visual Basic 6.0 program, that demonstrates how to get the current Hebrew date,
'  using the .NET mscorlib.tlb
' Project -> References -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb
'  on my Windows Vista system
Private Sub Main()
  ' Uses Karl Peterson's MConsole.bas, available from http://vb.mvps.org/samples/Console/
  Dim Hebrew As New mscorlib.HebrewCalendar
 
  TheYear = CStr(Hebrew.GetYear(Date))
 
  ' TODO: Expand for inclusion of all month names
  Select Case Hebrew.GetMonth(Date)
  Case 6
    TheMonth = "Adar"
  Case Else
    TheMonth = CStr(Hebrew.GetMonth(Date))
  End Select
 
  TheDay = CStr(Hebrew.GetDayOfMonth(Date))
 
  ' Uses Karl Peterson's MConsole.bas, available from http://vb.mvps.org/samples/Console/
  Con.Initialize
 
  ' You can use a MsgBox here if you don't use MConsole.bas
  ' MsgBox TheMonth + " " + TheDay + ", " + TheYear
  Con.WriteLine TheMonth + " " + TheDay + ", " + TheYear
End Sub

The code above does not test for leap years, but that can be determined using the IsLeapYear Method.

The HebrewCalendar Class has these and many more properties and methods.

VB6 Simple Property-Grid (ADO-Rs-Binding)

$
0
0
Just a very basic Property-Grid, thought as a base for your own enhancements.

The two User-Controls (ucPropertyGridStripe and ucPropertyGrid) contain in Sum only about 100 lines of Code,
so it's still relatively easy to understand how everything plays together - before you adapt the thing to your
own purposes (e.g. currently only plain-textfields are used, but depending on the Rs-Field-Type, a CheckBox
could be shown for Boolean Rs-Fields, etc.).

Nonetheless, the small thingy already scrolls properly - it already contains an .EnsureVisible method and
it reacts to changes on the outside Rs - and it raises Field-Change-Events appropriately - that's what the
small Demo-Form is trying to show.

Download here:
http://vbRichClient.com/Downloads/Si...opertyGrid.zip

and the usual ScreenShot:



Olaf

VB6 lightweight PNG-Controls (4-State-PngButtons and a moveable Png-Image/Sprite)

$
0
0
The small Demo shows a lightweight Implementation of GDI+ based Png-Handling,
encapsulated in two small and resource-friendly windowless Controls...

It's a variation (with some improvements) from my other CodeBank-post here:
http://www.vbforums.com/showthread.p...ely-per-WIA%29

One is for (Moveable) Images or Sprites -> ucPngPicture.ctl - the other is to handle
"4-State-Png-Image"-based Buttons (Normal, Hovered, Pressed, Disabled) -> ucPngButton.ctl.

Here's a ScreenShot, what the combined 4-State-Button-Pngs look like:


The Button-States-PngResources could also be adjusted to work with 5 States (e.g. when
you want to introduce also a "Focused" State - its just about enhancing the Png-Resource
about the new "State-Area" - and adding a few lines of code, which ensure the correct
Offset within the Controls "Refresh-Drawings"-routine.

To incorporate it into your existing Projects, you will have to include the 4 Files:
  • modPngCache.bas <- only contains a global Definition of PngCache As cPngCacheGDIp
  • cPngCacheGDIp.cls <- the GDI+ Handling (APIs and conversion into a 32Bit VB-StdPicture-DIB)
  • ucPngPicture.ctl <- the Png-Image- or Png-Sprite-Control
  • ucPngButton.ctl <- the (currently) 4-State-Png-Button-Implementation


Here's the Download-Link:
http://vbRichClient.com/Downloads/Pn...AndButtons.zip

The Source-Code within the Form is quite small (BTW, also demonstrating the
usage of VBs Usercontrols built-in HitTest-capabilities):

Code:

Option Explicit

Private Sub Form_Initialize() '<- early loading of all Png-Resources under their Keys (before Main-Form_Load)

  'here we add true Alpha-Channel-Png-Images to the cache (with 4 Button-States per Image)
  PngCache.AddImage "Home", App.Path & "\Res\Home.png"
  PngCache.AddImage "Seven", App.Path & "\Res\Seven.png"

  'now we cache another Alpha-Png, which will be rendered in a moveable Control
  PngCache.AddImage "Tucan", App.Path & "\Res\Tucan.png"
End Sub

Private Sub Form_Load()
  'just VBs normal LoadPicture-Function, providing the Forms BackGround-Img from a *.jpg
  Set Picture = LoadPicture(App.Path & "\Res\Checker.jpg")
End Sub

Private Sub Form_Resize() 'this adjusts the two Btns, which share the "Seven"-Key at the LeftBottom-Form-Edge
  ucPngButton(3).Move 7, ScaleHeight - ucPngButton(3).Height
  ucPngButton(4).Move 54, ScaleHeight - ucPngButton(4).Height
End Sub

Private Sub Form_Paint() '<- now that's iportant here for flickerfree rendering
  'to receive Form_Paint-Events, the Form needs to remain at the default (AutoRedraw = False)
  'then we need to ensure, that each and every Png-Usercontrol we use on this Form, gets refreshed

 
  '...starting with the Z-ordering "Bottom-Up" (the first refr. ucPng-Ctl is "bottom-most", a.s.o.)
  ucPngPicture1.Refresh
 
  Dim i As Long 'after the movable Png-Picture-Ctl above, we follow up with our 4 Png-Buttons below
  For i = 1 To 4: ucPngButton(i).Refresh: Next
End Sub

Private Sub ucPngButton_Click(Index As Integer)
  Caption = "ucPngButton " & Index & " -> " & ucPngButton(Index).Key
End Sub

'just a demonstration of the HitTest-Event (which by default, when not explicitely handled - would
'detect a Hit on the current *rectangular* Ctl-Region) - here we adjust the Hit-Detection with the
'"circle-formula" -> R = Sqr(x^2 + y^2), to the circular region of the round Buttons, so when you move
'the Mouse diagonally across the Button-"edges", it should give a hit only when you cross the circumference

Private Sub ucPngButton_HitTest(Index As Integer, X As Single, Y As Single, HitResult As HitResultConstants)
  Const R = 20 '<- we define a Radius of 20 Pixels for our userdefined HitTest
  Dim cx: cx = ucPngButton(Index).Width / 2
  Dim cy: cy = ucPngButton(Index).Height / 2

  HitResult = IIf(Sqr((X - cx) ^ 2 + (Y - cy) ^ 2) < R, vbHitResultHit, vbHitResultOutside)
End Sub

And the appropriate ScreenShot of the small Demo-App:


Have fun with it...

Olaf

VB6 Restoring NWind.db InMemory from ResourceBytes (without touching the FileSystem)

$
0
0
Sometimes there's the problem, to ship your App with a less than simple store, which contains "structured static Data" (e.g. a small catalogue-DB or a DB which contains the word-archives for your small spellchecker or something like that)...

If possible you will have the additional requirement, to ship it within your Executable (or Dll or OCX) - directly as a Binary-Resource (a "compiled into" ByteArray if you want).

Ok, one could do that e.g. with a JET-DB - (and compress and encrypt the FileContent into Bytes) - but in this case you'd have to "decrypt and unpack" into the Filesystem, to be able to use your DB-Data from the compiled-in ResourceBytes.

That last step (the FileSystem-Placement) is often not wanted - but the comfort of a DB (fast queries, joins, filters etc.) shall also remain possible - OK - with SQLite as the JET-alternative one can fullfill that need, since it allows true InMemory-Databases.

The following Demo contains a small example which is acting on NWind.db-content and performs both directions:
  1. the "packing-process" from a filebased DB -> ending up with compressed and RC4-encrypted ResourceBytes
  2. and the opposite direction (decryption/decompression/InMemory-DB-Creation from a plain ByteArray)

The Sources depend on the vbRichClient5-Project-Reference (Download available here: http://vbRichClient.com):

Here comes a ScreenShot:



And here the Project-Download-Link:
http://vbRichClient.com/Downloads/SQ...omResource.zip


Have fun with it...

Olaf

Need Advice on SOAP

$
0
0
Hello

I am using Visual Basic 6.0, I have downloaded Microsoft SOAP Toolkit 3.0. I do not have experience in using SOAP, I have been asked to interface with AVAYA NOTIFICATION and they have given me some examples. I really don't know where and how to start with. Please check on the below code and please advise me on what I should do to be able to make it work.

Example of the SOAP request (Email message):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com="http://common.service.ans.sca.aps.avaya.com/">
<soapenv:Header/>
<soapenv:Body>
<com:createMessage>
<arg0>
<attachment>http://148.147.181.48:8080/upload/wavefile.wav</attachment>
<body>fire alret for this building</body>
<channelType>EMAIL</channelType>
<expirationTime>1000</expirationTime>
<fromAddress>admin@ans.com</fromAddress>
<fromName>?</fromName>
<locale>en-US</locale>
<partitionName>default</partitionName>
<subject>Email Alert</subject>
</arg0>
</com:createMessage>
</soapenv:Body>
</soapenv:Envelope>

Thanks

VB6 TLSSend

$
0
0
TLSSend is a email sending program designed to demonstrate multiple methods of sending an email via SMTP.
1. Standard SMTP using port 25.
2. Standard SMTP with PLAIN AUTHENTICATION using port 1025 (May vary with ISP).
3. TLS 1.0 encrypted SMTP through smtp.gmail.com using port 465.
4. TLS 1.0 encrypted SMTP through smtp.gmail.com using STARTTLS and port 587.
5. TLS 1.0 encrypted SMTP through smtp.live.com using STARTTLS and port 587.
6. Yahoo does not support external access to SMTP for freebie accounts.

Normally, email settings would be stored in the registry or an initialization file, but since this is a demonstration program, your specific account details will have to be incorporated into the code.

- Change the generic To: & From: addresses in frmTLS.
- Change the "yourISP" Combo Box items in the frmTLS.Form_Load sub to reflect your own ISP.
- Change the generic account settings in the cmdConnect_Click sub to reflect your own account settings.

This program does not contain any third party controls or libraries, and utilizes the RSA/Schannel library (schannel.dll) that is shipped with all modern Windows Operating Systems. Although the Cryptography routines will work on most Operating Systems, cSocket2 will only work on systems that support dual stack (IPv4/IPv6). This more or less restricts it to Windows Vista or better. For more information on the Cryptographic functions, see:
http://www.vbforums.com/showthread.p...-VB6-TLSCrypto

J.A. Coutts
Attached Files

This Thread is for Nightwalker83...

$
0
0
Here is the Attachment of the proper ActiveX Control that you have requested for me to upload for you. I really hope that you enjoy this, ofcourse that there isn't any kind of viruses that have been attached to it, I have just scanned them prior to uploading them. Please note that there was a reason for me to remove the graphics, music, sound and also the video from this project. But then they have been included into the Resource File for safe keeping. I cannot remember if I have left in the video, sound, music and what not. But then I am totally definatly sure that I have kept the Graphics inside it, for you to use inside only that project, you are allowed to do so, with them and the source code in that project, with that project alone. That is my only request for you to do, fo me. Programmer to Programmer, so to speak...
Attached Files

VB6 applied physics, using the chipmunk-engine (simple Demo for Starters)

$
0
0
This simple "Physics-Engine usage for Starters"-Demo depends on the vbRichClient5.dll,
downloadable here: http://vbrichclient.com/#/en/Downloads.htm

So, before you can run it you will have to unpack the 3 Dlls from the above linked vbRC5BaseDlls.zip
into a Folder (e.g. C:\RC5\)... and then only register (in AdminMode) the vbRichClient5.dll per regsvr32.

There's no need to copy the Dlls into the same Folder where you unpack the Zip of our small Demo-Project here:
http://vbRichClient.com/Downloads/ChipmunkCairo.zip
Meaning you can run all further RC5-based Demos directly from within their Unpack-Target-Folders,
without having to bother again with the (only once) to install RC5-BaseLibs.

The chipmunk Physic-Engine is wrapped up behind easy to use VB-Classes - no need to take care about
handle-freeing or other stuff (when you'd be using the "plain-C" chipmunk-API)...

For 2D-game-developers this should be quite interesting, since it allows all kinds of physics based games,
which involve e.g. true Car-Physics, or the whole class of "Rubberband-based games" - or shooting some Objects
around, which will follow true flight-parables with only a given Impulse... or all kind of simpler games where
Ball-bouncing-Physics are involved.

The Collision-Detection is sophisticated (respecting Mass, Elasticity, Friction, Momentum) though still quite performant,
even with a larger amount of moving Objects or irregularly shaped "fixed-bodies" in your scenes.

This last part, the construction of complex shapes is a speciality I've included in the Wrapper, since it allows
the Construction of any shape-form with ease over simple Cairo-Drawing-Calls (Cairo-Paths) - and that includes
even as complex shapes as rendered Text - the Demo here will already demonstrate, that the Ball-Objects take
even such complex-formed fixed shapes as rendered Text(Paths) seriously in their collisions...

One can see that easily witht a good look at the ScreenShot below... (where the Balls ended up finally after
bouncing around) - they "lean on each other" and rest with their bottoms on the TextChars exactly
(the left Ball on the "dot of an i" - and the right Ball is "hanging" between the highest points of "k" and "h"):



The Drawing-Capabilities of Cairo include SubPixel-based Rendering of Png-based Sprites, as well as
normal Vectordrawn-Shapes ... this (antialiased) SubPixelprecision-output is quite important
especially with slower moving Objects - and cairos internally used Double-Precision matches exactly with
the Double-Precision each of the Body-Shape-Objects is internally repositioned by the Physics-Engine
in each (highres) Timer-Step.

I'll post some more Demos about this Engine, for the moment this simpler one may be sufficient as a
Base for your own experiments (with different Shapes or maybe only some Fiddling with the Parameters,
as e.g. the Gravity - or the Elasticity and Friction of the Balls).

Have fun with it.

Olaf

VB6 NewSocket

$
0
0
The original CSocket/SocketMaster emulated the Microsoft Winsock Control. cSocket2 introduced the newer Dual Stack calls that would support IPv6 as well as IPv4 , but remained procedurally the same. All of them supported the sending/receiving of all types of data (byte, string, integer, long, etc). WSA sockets treated everything as byte data and could care less what type of data it was, and it was up to the higher level programs as to how that data was treated. What I found was that all my programs utilizing cSocket2 used string data, which made a lot of the code used to support data types unused and redundant. Even though the conversion of Unicode string data (16 bit) to byte data (8 bit) was inefficient, VB6 contained a plethora of commands that made manipulating string data relatively easy, and inherently took care of garbage collection.

NewSocket sends and receives string data only. There is only a single conversion made to and from byte data.

I was not happy with the way cSocket2 handled errors, so now all errors are returned to the calling program for handling through the Error Event.

Modern Cryptographic techniques are built on top of TCP/IP, so a new Event called "EncrDataArrival" was added along with a flag to allow incoming encrypted data to be treated differently from plain data.

Originally, the LocalPort(PropertyGet) routine would simply return the value of m_lngLocalPort, which was assigned during the Bind process. However, GetAddrInfo automatically assigns the first available socket on a Connect call (Bind not called), and the routine would return zero. It was changed to use GetLocalPort.

J.A. Coutts
Attached Files

VBA Code

$
0
0
Hi!
I've been trying for a few time to make a sub, on VBA, that writes, in a specific column, " " or 1 depending on the date that is inserted. The thing I can't quite do is:
1 - I have a sheet where the different projects of a company are stored (name, starting date, ending date and person responsible) and where new projects can be added from a UserForm
2 - I also have another sheet were costs from the projects are stored (one line with cost 1 from project 1, another with cost 2 also from project 1 and cost 3 from project 2, etc) and where I can also add a new cost with another UserForm (this cost as also a date that is added, to when it happened)
3 - What I need to do is, on the costs' sheet I need to create a sub that in the last column adds me 1 if the date of the cost added is not a date between the starting and ending date of the project that it corresponds.
Can anyone help me on this??
Thank you very much :)

VB6 - WIA "BlendPaint" Demo

$
0
0
In honor of the death of Windows XP (which means there is no excuse for VB6 programmers to ignore these techniques any more) here is an example of some of the simple things you can use the Windows Image Acquisition Library 2.0 for.

WIA can do other things for you as well such as trivially extract JPEG EXIF data including thumbnail images and perform many scanner and still-image camera operations. In particular the loading of PNG or TIFF images and saving images in GIF, JPEG, and TIFF are provided via WIA.

However this sample program only shows a few of the things WIA can help you do with little code.

If you can find the old WIA 2.0 SDK you can deploy the library back as far as WinXP SP1 machines if necessary. However the download was pulled from Microsoft Downloads some time ago.


This demo illustrates a couple of things such as image loading with WIA, extracting a Form or PictureBox image to a WIA ImageFile object for use in operations such as saving to disk, and simple use of WIA's ImageProcess object's "Stamp" filter for compositing with transparency and PNG alpha blending.

It doesn't go into the details for other filters such as Convert, RotateFlip, Crop, Scale, etc. but those are documented elsewhere. Filters can even be applied in a group to perform multiple operations at once.

By using the persistent bitmap of a Form (and a smaller PictureBox) this demo shows how you can intermix WIA Stamp with VB6 drawing operations in "layers." Note that GIF transparency and PNG transparency and alpha channel blending are supported.

Name:  sshot.png
Views: 82
Size:  55.9 KB

Screenshot of the demo. Note that this capture was compressed down
to 8-bit color and the actual results look better.

Here all of the images are loaded from disk files. However you can also use WIA to load images from custom resources, or even from sources such as downloaded data without writing them to disk first.
Attached Images
 
Attached Files
Viewing all 1325 articles
Browse latest View live




Latest Images