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

Hyperlink Control

$
0
0
This is a UserControl for simulating a Hyperlink. The control is build up by a simple label.
But it have some advantages comparing to a simple label putted on a form.

It will show up a hand cursor when the mouse is over the control. In addition a hover effect can be used when the mouse is over it.
The control itself can receive focus, which is very helpful for keyboard users. But it only keeps the focus when control is not entered by mouse.

The control fires a "Jump" event. In that event the code should be put to open a url, document or anything else.

Attachment 90515

Attachment: Sample project with the hyperlink (user)control.

EDIT1:
- It now supports a ColorUsed property.
- The focus can be navigated now with the arrow keys within the controls container.
- Added a PrepareJump event where the user can set if the LostFocus Event will always be fired or not. (Example Usage: Calling a MsgBox in the Jump Event will not fire the LostFocus Event. Therefore a possible focusrect drawing is still visible while the MsgBox is displayed)
- other minor improvements

EDIT2:
- It now supports the system hand cursor. Therefore added a CursorCustom property. If set to False the system cursor will be used, otherwise it uses a custom cursor like before.
- other minor improvements
Attached Images
 
Attached Files

[vb6] Module: GetDataFromURL

$
0
0
Originally, i writed this module for self. Now i'm publish module for others. :)

This module created for the send GET\POST queries to the server.

GetDataFromUrl: - Sending request to remote server.
strURL - URL of the target page.
Optional strMethod = GET - Page request method: GET, POST or Multipart. (POST with multipart)
Optional Async = false - Run in asynchronous mod. (To prevent gui lags).
Optional strPostData = "" - Data to post. (Only if strMethod = POST\Multipart)
Optional boundary = "" - Boundary for multipart. (Only if strMethod = Multipart. Create with Make_Boundary.)

Make_Boundary: - Making Boundary for POST + multipart request.

Add_Multipart: - Adding fields for POST + multipart request.
post_field - Field.
post_data - Value of field. Leave empty, if you sending a file.
boundary - Boundary. (Create with Make_Boundary.)
Optional file_path = "" - Path to file. Leave empty, if you want to send post_data.Attachment 90481


GET request example:
Code:

Dim ansv As String
ansv = GetDataFromURL("http://vbforums.com")

POST request example:
Code:

Dim ansv As String
ansv = GetDataFromURL("http://vbforums.com", "POST", false, "field1=value1&field2=value2")


POST request with multipart example:
Code:

Dim ansv As String
Dim Multipart As String
Dim Boundary As String

Boundary = Make_Boundary

Multipart = Add_Multipart("Field1", "Value1", Boundary)
Multipart = Multipart & Add_Multipart("Field2", "Value2", Boundary)
Multipart = Multipart & Add_Multipart("File2", VbNullString, Boundary, "C:\test.txt") 'File upload example
Multipart = Multipart & "--" & Boundary & "--"


ansv = GetDataFromURL("http://vbforums.com", "Multipart", false, Multipart, Boundary)

---------------------------------
I hope you enjoy it. :) Sorry for my bad english.

Attachment 90481
Attached Files

[VB/VBA] LunarPhase - Phase of the Moon

$
0
0
When you don't need it, you don't need it. But when you do it can take a little thinking through.

The basic concept is fairly easy if you simply need rough, non-astronomical results. Take your target date/time, find out how far it is from a base date/time with a known phase (say New Moon), take the Lunar phase cycle period, and then the result is easy:

Phase = Delta Mod Period

Usually you'll want the value in more granular form. Maybe quarters is good enough, etc. so just divide the "Phase" value by the fraction of "Period" you want for granularity.

Another refinement is to make sure your base and target times are for the same time zone so you can avoid being off by 0 to 24 hours.


Here I used a UTC "base" New Moon date & time so I correct local time to UTC before calculating (this function is in the attached demo project). I found 24 images for the entire cycle so I am returning a phase value that is 1/24th of a Lunar period. I was careful to reduce the use of non-integer arithmetic and avoid rounding.

So hopefully this works out reasonably accurately for simple "display the phase of the Moon" purposes:
Code:

Public Const PhaseBase As Date = #1/17/1980 9:18:00 PM# 'GMT/UTC.
Public Const LunarSynod As Long = 42524    'Minutes.

Public Function LunarPhase(ByVal TargetDate As Date) As Integer
    'Returns lunar phase for TargetDate starting from PhaseBase
    'timestamp forward, at 1/24 cycle intervals, i.e. values
    'from 0 to 23:
    '
    '    0 = New Moon
    '    6 = First Quarter
    '  12 = Full Moon
    '  18 = Last Quarter
   
    LunarPhase = _
        (Fix(DateDiff("n", PhaseBase, ToUTC(TargetDate))) Mod LunarSynod) _
      \ (LunarSynod \ 24)
End Function

I've wrapped it in a small demo application for testing.
Attached Images
 
Attached Files

[VB6] - Lottery-Algorithm

$
0
0
On a german Forum I developed the following Lottery-Algorithm (which i haven't found on the Internet in this form).

I would like to hear your opinions and/or suggestions to improve it

vb Code:
  1. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
  2.  
  3. Sub Lottery(ByVal DrawNumbers As Long, ByVal TotalNumbers As Long)
  4. Dim arrSource() As Long    
  5. Dim arrDest() As Long
  6.  
  7. Dim i As Long
  8. Dim j As Long
  9. Dim Counter As Long
  10. Dim RandomNumber As Long
  11.  
  12.     'What Lottery is played
  13.     ReDim arrDest(1 To DrawNumbers)
  14.     ReDim arrSource(1 To TotalNumbers)
  15.    
  16.     'Create Source-Array
  17.     For i = 1 To TotalNumbers
  18.    
  19.         arrSource(i) = i
  20.    
  21.     Next
  22.    
  23.     Counter = 0
  24.  
  25.     Randomize
  26.  
  27.     Do
  28.  
  29.         RandomNumber = Int(UBound(arrSource) * Rnd + 1)
  30.    
  31.         Counter = Counter + 1
  32.         arrDest(Counter) = arrSource(RandomNumber)
  33.        
  34.         'Cutting out the RandomNumber drawn
  35.         For j = RandomNumber + 1 To UBound(arrSource)
  36.        
  37.             CopyMemory arrSource(j - 1), arrSource(j), 4
  38.            
  39.         Next
  40.        
  41.         'Cut down the Source-Array
  42.         ReDim Preserve arrSource(1 To UBound(arrSource) - 1)
  43.            
  44.     Loop Until Counter = DrawNumbers
  45.    
  46.     For i=1 to DrawNumbers
  47.      
  48.          Debug.Print arrDest(i)
  49.  
  50.     Next
  51.  
  52. End Sub
  53.  
  54. 'Calling the function with
  55. Call Lottery (6, 49)

Caption Gradiator III / VB6 Form Gradient Titlebar

$
0
0
Hello, :wave:

Caption Gradiator III is a Basic Module that facilitates a custom gradient color titlebar for Visual Basic forms. The original program came from another VB author's web sight. The code was bloated and had several bugs including the failure to repaint area around the form control box buttons. The original author's approach to fixing the bugs was to tie the process to a sub class timer thereby increasing the bloat. My approach was to use better logic and less code. I learned from the original code as opposed to copying the code. The changes I made were significant and I have no problem with calling this my own program. The process is called from the Form_Load event and cancelled in the Form_Unload event as illustrated in the form code in the project.

Enjoy,
OldRon, aka servowizard
Attached Files

MemoryView

$
0
0
This started as a simple program to show a hex dump of 'safe' memory addresses,
i.e. those returned by VarPtr, StrPtr, VarPtrArray, and an undocumented
function, StringArrPtr.

After playing with it for a bit, I got interested in how VB stores its variables in memory
and this is the result.

It uses CopyMemory liberally, so if you start tweaking it, be careful and
save your project before running in case you crash VB. (You can select
Tools|Options|Environment and click on Save when program starts.)

The program allows you to examine numeric values, numeric arrays, numeric safe arrays,
string values, string arrays, string safe arrays, and UDTs (Types).

Here's a sample output

**Long variable with value of &H4030201
Start Address: &H0013F8AC Number of Bytes: 16
________________________________________________________________________________
Base: OS: Hex: Ascii:
0013F8AC 0000 01 02 03 04 40 F9 13 00 10 FA 13 00 01 00 00 00 ....@...........
________________________________________________________________________________
Attached Files

VB6 - Melas: Line Charting Classes

$
0
0
Why Melas?

I needed an alternative to the MSChart control for creating simple line charts in batch mode. MSChart can do the job just fine with some fiddling, however I needed to create these charts and write them as JPEG or PNG files for direct serving from a Web server. The only snag is that to capture the drawn chart from the MSChart control you need to use the clipboard and I didn't want to disturb its contents since a user might well be working while a background charting operation was going on.


What is Melas?

There is a main class called Melas and a set of "child" classes it uses to represent various things (axes, plots, legends, etc.). You create an instance of Melas and initialize it with a reference to some VB6 object having an hDc so that it can be drawn on. In most cases this will be a Form, a PictureBox, or a UserControl.

From there you use some MSChart-like operations to flesh out the rest and plot your lines.


Still Rough

There is more to do here yet, especially in terms of dealing with pesky boundary conditions (do I subtract a pixel here or not?), making sure rotated text gets positioned correctly, etc.

However I decided to post it as-is.

For one thing it is still simple enough that somebody could use it as an example or jumping-off point for creating their own more comprehensive MSChart alternative. For another I am taking the code in a specific direction for my own purposes that will make the logic more complex to follow as well as being less general-purpose in nature.


Notes

There is no code here to grab the resulting chart image and save it, the focus here is drawing the chart. You can use simple .SavePicture() operations to create BMP files or else use another technique to grab and save in other formats.

The core of the Melas classes is the Canvas class, which is primarily meant to create non-clipped and clipped regions where the Y-coordinate is flipped (0 at the bottom instead of the top as in regular VB6 drawing) and both X and Y are scaled without using a custom ScaleMode.

Inside the Melas class you will find places where it uses Canvas coordinates, and others where it draws directly and uses VB6 cordinates. Sorry about the confusion - this is just a heads-up to anybody trying to unravel the logic.

The attachment contains the Melas classes and 5 demos. There are some images in there and a small database, which is why the attachment is so large. Melas itself is fairly small and doesn't add a ton to the size of compiled programs.
Attached Images
     
Attached Files

VB6 IDE solving UAC and Visual Style issues

$
0
0
Hello,

the VB6 IDE (VB6.exe) has issues when the UAC (Windows Vista and 7) is activated.
This may cause that opening .vbp files for example will fail.

To solve this it is just required to add a resource directly into the VB6.exe.

The source code of "RequireAdmin.res" is:

Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
        <requestedPrivileges>
            <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
        </requestedPrivileges>
      </security>
  </trustInfo>
</assembly>

In the attachment I have added the same as a compiled resource.

Use a resource hacker to put the resource file directly into the VB6.exe.
I used following resource hacker for that job: http://www.angusj.com/resourcehacker/
(File -> Open ... VB6.exe -> Action -> Add a new Resource ...)

The result is now that every time the VB6.exe will be accessed it is ensured that the admin rights are on.
Opening .vbp files works therefore without any problems.

I have also attached another compiled resource file with visual styles included, just for those who want it too.

The source code of "VisualStylesAndRequireAdmin.res" is:
Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
        <requestedPrivileges>
            <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
        </requestedPrivileges>
      </security>
  </trustInfo>
  <dependency>
      <dependentAssembly>
        <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"/>
      </dependentAssembly>
  </dependency>
</assembly>

EDIT: Reason for this is that adding a manifest file into the VB6.exe directory won't work anymore in Windows 7.
Attached Files

VB6 - SysBitmaps Control: Free Toolbar images, from Windows

$
0
0
Here is a quicky for populating toolbars with standard bitmaps embedded in comctl32.dll.

There is still (at least) one bug: if you load some large (24x24) bitmaps and then shift and load some small 916x160 bitmaps the small ones get corrupted. probably an issue with the way I'm using PictureBoxes in there.

This is a control and not a class so that I can use those PictureBoxes to cut up the image-strip bitmaps instead of doing a lot of GDI API fiddling.
Attached Images
 
Attached Files

Translator with Sound/Speech

$
0
0
Here is a little word translation sample i would like people to have.. if you have any questions feel free to ask. you can also download the sounds/speech, ask me how if you need and i will show you how

i only used textbox and mine does not display (chinese,arabic...) languages its shows up as ?????... if you need other languages i would recommend switch to other types of control that will support other languages such as "Microsoft Forms 2.0 Object Library" (or other controls)

Speech translation will work however, even if it does not display correctly in textbox

anyways here is a working translator with sound


***Additional*** Example of how to get speech/sound status
Code:

Private Sub Command1_Click()
WindowsMediaPlayer1.URL = "http://translate.google.com/translate_tts?ie=UTF-8&tl=" & GetLanguage(cmbTo) & "&q=" & ieGoogle.document.getElementById("result_box").innertext
ChangeStatus "Loading Speech/Audio...."
Do Until WindowsMediaPlayer1.playState = wmppsPlaying
  DoEvents
Loop
ChangeStatus "Playing Speech/Audio..."
Do Until WindowsMediaPlayer1.playState = wmppsStopped
  DoEvents
Loop
ChangeStatus "Ready"
End Sub

Private Sub Command2_Click()
WindowsMediaPlayer1.URL = "http://translate.google.com/translate_tts?ie=UTF-8&tl=" & GetLanguage(cmbFrom) & "&q=" & txtTranslate.Text
ChangeStatus "Loading Speech/Audio...."
Do Until WindowsMediaPlayer1.playState = wmppsPlaying
  DoEvents
Loop
ChangeStatus "Playing Speech/Audio..."
Do Until WindowsMediaPlayer1.playState = wmppsStopped
  DoEvents
Loop
ChangeStatus "Ready"
End Sub

Private Sub cmdTranslate_Click()
On Error Resume Next
  Command1.Enabled = True
  Command2.Enabled = True
  txtResult.Enabled = True
  txtResult.Text = ieGoogle.document.getElementById("result_box").innertext
 
  ChangeStatus "Preparing Speech/Audio...."
 
  WindowsMediaPlayer1.URL = "http://translate.google.com/translate_tts?ie=UTF-8&tl=" & GetLanguage(cmbFrom) & "&q="
 
  Do Until WindowsMediaPlayer1.playState = wmppsReady
    DoEvents
  Loop
  ChangeStatus "Ready"
End Sub

Attached Files

VB5/6/VBA - HeapsortVarVar, Another VB Sort

$
0
0
This is a VB6 static (.BAS) module for sorting a Variant array of Variant arrays using the Heapsort algorithm. It could easily be converted to a class (.CLS) if desired as well.

It should be usable in VB5 and VBA, but this hasn't been tested. it should even be convertable to VBScript, though with much reduced performance of course.


Why VarVars?

When I need to work on large sets of row/col-based (tabular) data and I can't use a database or ADO Recordset I find Variant arrays of Variant arrays handy. Much handier then a 2-D array of String because I can used typed data, far less clunky than working with inflexible UDT arrays where you can't iterate over the fields, and even more useful than 2-D Variant arrays.

Typed data instead of String for everything can be very useful. In a field typed as Single, Double, Currency, etc. 2 and 2.0 will compare properly.

For another thing you can build a "row" of fields easily just using the VB Array() function, then assign it to a "row" slot in your Variant rows array.


Why Heapsort?

The Heapsort is reasonably speedy, doesn't require additional space, and performs well even in worst-case input sequences.

But the main reason is that it is easy to modify to perform the sort in several steps. This makes it possible to use a Timer control to drive a "background" sort that doesn't cause your programs to become unresponsive. This does add to the time a little, but the Timer.Interval need only be 16 to 32 milliseconds for most purposes. It also allows you update progress bars, handle "cancel" button clicks, etc.

This has always been the preferred way to handle this in VB6, as the manual states in many places. DoEvents() calls have their place, but DoEvents() is evil, should rarely be used, and even then only used quite carefully.

However both a synchronous sort and a quantified "pseudo-async" sort are provided here.


Usage

Basically, just add HeapsortVarVar.bas to your projects.

Then when you have a Variant array of Variant arrays to sort, call the SortBy() subroutine (or the QuantumSortBy() function until it returns False).

You pass the column index to sort on, the outer (rows) array to be sorted, and an optional Boolean Descending value (True or False, default False) to specify the direction of the sort.

QuantumSortBy() has two more parameters but the source code comments should explain those. These need to be initialized before the first call of each sort to be performed.

There are no extra dependencies.


Issues

There are sorts that can be faster, Quicksort is popular. However they aren't usually enough faster to warrant sacrificing some of the things that are easy to do to Heapsort (e.g. a quantified pseudo-async version).

If you create a Quicksort adapted for this I'd love to see it. Right now HeapsortVarVar works plenty fast for me, but more speed without additional pain is always appreciated.

Bugs. As far as I can tell there aren't any, but if you find some I'd like to know about them.

I find this very versatile, and once "known bug free" it should make a useful and easily reusable sort for VB users. While you can use it for sorting single items, it would be better to just create a new version tailored to work on a simple single-valued 1-D array.


Demos

There are two in the ZIP archive attachment. They are "ready to run" with a sample input file included, though I'd try testing after compiling to an EXE first. There is more data included than it appears, though it ZIPpped fairly small because it's about 1500 records copied into the file multiple times. The sort isn't too bad even in the IDE, however populating and re-populating the flexgrid can take a while.

Yes, I know the flexgrids can sort, but here it is just being used for demo purposes.

HeapsortDemo

This is a GUI program that loads and parses the sample data into a VarVar and displays it in an MSHFlexGrid. Then you can click or shift-click the column headers to sort and redisplay the VarVar contents.

Yes, there are a couple of UI quirks, related to the column click selecting cells in the grid. The program tries to clear these selections but it doesn't always succeed. The grid is merely being used for demo purposes here anyway. But you may already know of a fix for that if you care.

DeleteDups

A simpler program without any Forms that loads up the sample data, then sorts on the second column as a Single value, then
writes a new file including only the first row for each unique "second column" value.

It uses MsgBox calls to display when it reaches each phase and the time each phase takes.
Attached Files

VB6 - SillyStream Encrypted Text I/O

$
0
0
While hand-rolled encryption is never a good idea, sometimes you don't need a high-security solution. SillyStream is a text I/O class that you can set a few parameters on and then do low-volme encrypted text file I/O. It would need optimization if you really need to work on large files, but it was really intended for smaller items such as settings files.


Usage

Pretty simple, just add SillyStream.cls to your Project. Then create instances as you need them (eaach only handles one file at a a time). Call Init() to set the parameters, then one of the open methods (input, output, append), and use the read and write methods, and finally the close method. Then you can open a new file either with or without setting new parameters first.


Parameters

There are two mask values (one a Byte, another a Long) and two dimensional parameters. These have funny names in the class and in the demo Project. See the comments for an explanation.


Cipher Used Here

This is a combination cipher, based on two very very simple ciphers.

The main feature here is a transposition cipher using the two dimensions provided to create a buffer block as a matrix. When writing or reading the file, the data is an inversion of this matrix.

On top of that we have simple (really simple) substitution cipher. All of the data characters a XORed with a one Byte mask. With some effort you could use a longer "password" mask but it complicates things (especially "open append" operations).

The final block is padded with pseudorandom values.

Finally, to make this work even with a padded final block, the actual data length is stored in the first 4 bytes of the file as a Long value. This is XORed with the Long mask you provide to help obscure it a bit. Adding these 4 bytes has another advantage: It makes it all little tougher to crack because simply trying to factor the file size will be a bit of a red herring even if someone guesses it uses a rectangular transposition cipher.

Dumb but cheap, and perhaps good enough.


Demo

The demo Project lets you open a new files, type some stuff, write is as characters or as a line 9adding newline), etc, and then close. Then you can read it back and see it displayed, using both reading by byte count or the slower reading by line.

Even though slower, I expect most people to just read by line most of the time. Writing by line is probably going to be more useful then by text length as well.

Sample inputs:
Code:

This is a test.
This is only a test.
How now, brown cow?
Mellow yellow, such a silly fellow!
Test test test test test test test test test test testing!

Hex dump:
Code:

0000        e5 54 12 f0 0f 2f 35 13  35 2c 33 37 28 2f 2f 3e  .T.../5.5,37(//>
0010        51 7c 07 8c 15 33 75 37  34 7b 7b 7b 34 2f 3e 7b  Q|...3u74{{{4/>{
0020        28 04 83 14 93 22 32 56  22 2c 38 22 3a 2c 7b 28  (...."2V",8":,{(
0030        2f 2f 0b 90 1b a0 29 28  51 7b 7b 34 3e 7b 7a 2f  //....)(Q{{4>{z/
0040        2f 3e 7b 18 97 28 a7 36  7b 0f 3a 35 2c 37 28 56  />{..(.6{.:5,7(V
0050        3e 7b 28 2f 1f a4 2f b4  3d 32 33 7b 34 64 37 32  >{(/../.=23{4d72
0060        51 28 2f 2f 3e 2c ab 3c  bb 4a 28 32 2f 2c 56 34  Q(//>,.<.J(2/,V4
0070        37 0f 2f 3e 7b 28 33 b8  43 c8 51 7b 28 3e 77 51  7./>{(3.C.Q{(>wQ
0080        2c 37 3e 7b 28 2f 2f 40  bf 50 cf 5e 3a 7b 28 7b  ,7>{(//@.P.^:{({
0090        16 77 22 28 2f 2f 3e 32  47 cc 57 dc 65 7b 32 2f  .w"(//>2G.W.e{2/
00a0        39 3e 7b 7b 2f 3e 7b 28  35 54 d3 64 e3 72 2f 28  9>{{/>{(5T.d.r/(
00b0        75 29 37 28 3d 7b 28 2f  2f 3c 5b e0 6b f0 79 3e  u)7(={(//<[.k.y>
00c0        7b 56 34 37 2e 3e 2f 2f  3e 7b 7a 68 e7 78 f7 86  {V47.>//>{zh.x..
00d0        28 34 51 2c 34 38 37 3e  7b 28 2f 56 6f f4 7f 0e  (4Q,487>{(/Vo...
00e0        8d                                                .

Hex dump of a test with the data XORing omitted. Normally you wouldn't do this but it shows that the transposition and padding can be effective all alone:
Code:

0000        e5 54 12 f0 54 74 6e 48  6e 77 68 6c 73 74 74 65  .T..TtnHnwhlstte
0010        0a af 30 b5 3c 68 2e 6c  6f 20 20 20 6f 74 65 20  ..0.<h.lo  ote
0020        73 37 b6 3d bc 49 69 0d  79 77 63 79 61 77 20 73  s7.=.Ii.ywcyaw s
0030        74 74 3e c3 44 c9 50 73  0a 20 20 6f 65 20 21 74  tt>.D.Ps.  oe !t
0040        74 65 20 4b ca 51 d0 5d  20 54 61 6e 77 6c 73 0d  te K.Q.] Tanwls.
0050        65 20 73 74 52 d7 58 dd  64 69 68 20 6f 3f 6c 69  e stR.X.dih o?li
0060        0a 73 74 74 65 5f de 65  e4 71 73 69 74 77 0d 6f  .stte_.e.qsitw.o
0070        6c 54 74 65 20 73 66 eb  6c f1 78 20 73 65 2c 0a  lTte sf.l.x se,.
0080        77 6c 65 20 73 74 74 73  f2 79 f8 85 61 20 73 20  wle stts.y..a s
0090        4d 2c 79 73 74 74 65 69  7a ff 80 0d 8c 20 69 74  M,ystteiz.... it
00a0        62 65 20 20 74 65 20 73  6e 87 08 8d 14 99 74 73  be  te sn.....ts
00b0        2e 72 6c 73 66 20 73 74  74 67 8e 15 94 21 a0 65  .rlsf sttg...!.e
00c0        20 0d 6f 6c 75 65 74 74  65 20 21 9b 1c a1 28 ad    .oluette !...(.
00d0        73 6f 0a 77 6f 63 6c 65  20 73 74 0d a2 29 a8 35  so.wocle st..).5
00e0        b4                                                .


Bugs

I havent found any, but if you do be sure to mention them.
Attached Files

[RESOLVED] [VB6] Coloring Excel Cell from VB6

$
0
0
Hi Guys,

Do you have any idea how to set excel cell from VB6 Codes?

Set ExlObj = CreateObject("excel.application")
ExlObj.ActiveSheet.Cells(1, 1).Columns.ColumnWidth = 18
ExlObj.ActiveSheet.Cells(l, m).Rows.BackColor = vbGreen << IS NOT WORKING

Thanks,
Jefri

How to Make a Round (Circular) Form

$
0
0
Ever want a round form? This short VB6 code will create it for you. I know it works on XP and Win7. Not tested on Win8.

Open a new VB6 project
I added two shapes and one label to the form---not necessary, but looks pretty! :-)
I use a Double-Click to unload the form, but you can use any ctrl/code you desire.

Code:

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_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)
    Shape1.Left = (Me.Width / 2) - (Shape1.Width / 2)
    Shape2.Left = (Me.Width / 2) - (Shape2.Width / 2)
    Shape1.Top = (Me.Height / 2) - (Shape1.Height / 2)
    Shape2.Top = (Me.Height / 2) - (Shape2.Height / 2)
    Label1.Top = (Me.Height / 2) - (Label1.Height / 2)
    Label1.Left = (Me.Width / 2) - (Label1.Width / 2)
End Sub
Private Sub Label1_Click()
  Unload frmRound
End Sub

Here's How to Make a Form With a HOLE in it.

$
0
0
Want a form that you can move around and see what is behind the center of it? Not sure what good it is, but it's kinda cool. Maybe you can find a good use for it. Noting to add to a project---only the form that you see when you start a new poject.

Code:

Option Explicit
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode 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 Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub Form_Resize()
Const RGN_DIFF = 4
Dim outer_rgn As Long
Dim inner_rgn As Long
Dim combined_rgn As Long
Dim wid As Single
Dim hgt As Single
Dim border_width As Single
Dim title_height As Single
    If WindowState = vbMinimized Then Exit Sub
   
    ' Create the regions.
    wid = ScaleX(Width, vbTwips, vbPixels)
    hgt = ScaleY(Height, vbTwips, vbPixels)
    outer_rgn = CreateRectRgn(0, 0, wid, hgt)
   
    border_width = (wid - ScaleWidth) / 2
    title_height = hgt - border_width - ScaleHeight
    inner_rgn = CreateRectRgn( _
        wid * 0.25, hgt * 0.25, _
        wid * 0.75, hgt * 0.75)
    ' Subtract the inner region from the outer.
    combined_rgn = CreateRectRgn(0, 0, 0, 0)
    CombineRgn combined_rgn, outer_rgn, _
        inner_rgn, RGN_DIFF
   
    ' Restrict the window to the region.
    SetWindowRgn hWnd, combined_rgn, True
    DeleteObject combined_rgn
    DeleteObject inner_rgn
    DeleteObject outer_rgn
End Sub


VB6 - MMapper, Memory Mapped File Demo

$
0
0
Background

People are often scrounging for easy to use IPC alternatives for Visual Basic programs. Windows offers a ton of choices, but unless you can state your requirements it is difficult for somebody else to make a recommendation.

One obvious route is to use a common disk file shared among your program instances (processes). This really isn't as bad as it sounds, but there is a somewhat lighter-weight alternative to a shared temporary file that often isn't considered.

Files can be mapped into shared memory, but we can go a step further and "back" such shared memory with the system paging file instead. This thread talks about some simple code to do this in a bare bones fashion.


MMapper

MMapper is a simple class using the basic set of API calls required to create, open, read, write, and close such a chunk of shared memory.

As written, it sets up a BLOB of bytes as shared and then treats it as a single place to write or read data that multiple processes can use. Since you do not get fine control over where this memory is mapped into your processes' address spaces it is normally used along with CopyMemory() calls.

MMapper handles this by accepting pointer and length arguments for its read and write methods. This means you can pass String variables, Byte arrays, or even UDTs that are flat (do not contain dynamic-length fields).


The Demo

The attached demo contains the MMapper class and two projects: Writer and Reader.

Writer is responsible for creating the mapped file and writing data to it. Reader opens this mapped file (which requires that it is first created by Writer) and reads data from it.

MMapper creates/opens the mapped file with read/write access, so the fixed roles of Reader and Writer are simply to make the operation easier to understand.

You could easily have every program (and every instance of each program) try to create the mapped file, and they could all both read and write. It's just a matter of figuring out how you want to coordinate things among all of the running processes, and that part is up to you.

Here I use a small UDT to pass one Long value and one String * 100 value.


Enhancements

It is easy enough to extend MMapper in several ways.

Some of these involve security options to allow sharing among users. You can also treat the mapped space as several separate items instead of one BLOB. And you can map an actual disk file, providing persistence across sessions.

See your MSDN Library CDs or Windows SDK for more details.

This even works on Win9x with a few limitations inherent in the platform (such as no Terminal Services or Fast User Switching or other multi-user support).
Attached Images
 
Attached Files

[VB6] Steam Account/Password Manager 1.0.1 (Account Safe, Fully encrypted) [SRC]

$
0
0
As i said a few weeks ago i believe 9 weeks ago. I was planning on making such a app.
Here is it. I made it a while ago by now. But uhm just uploads it now.

Demo:



Download:
See attached zip file.

Have fun and let me know what you think of it :wave:
Attached Files

CommonControlsEx (Replacement of the MS common controls)

$
0
0
This project is intended to replace the MS common controls for VB6.

As for now, the „MSCOMCT2.OCX“ can be replaced completly. (Except the FlatScrollBar control, because this is not supported on comctl32 v6.0)
The „MSCOMCTL.OCX“ can not yet replaced fully, as for example the ListView/TreeView control is missing. (But might be included soon)

These are the controls that are available at the moment:

- Animation
- DTPicker
- ImageList
- MonthView
- ProgressBar
- Slider
- TabStrip
- UpDown
- ToolTip (This is new, because it does not exist in the MS common controls for VB6)

For the ImageList and the TabStrip is a property page implementation. That means you can add items at design time.

At design time (IDE) there is only one dependency. (OLEGuids.tlb)
This is a modified version of the original .tlb from the vbaccelerator website.

But for the compiled .exe there is no dependency, because the .tlb gets then compiled into the .exe.

Attachment 93081

Attachment 93087
The underscores at the tabstrip control are added to demonstrate that the shortcut via ALT key is supported.

Attached is the demo project.
Everything should be self explained, because all functions and properties have a description.
Attached Images
   
Attached Files

Creating a window by using the API

$
0
0
The attached code (Create Window.zip) demonstrates how to use the CreateWindowEx API function to create a window and controls inside it.
Attached Files

Explore and create desktops

$
0
0
Desktop Explorer demonstrates get a list of active window stations and any desktops attached to them. The program also allows the user to create a new desktop and launch programs on it. Depending on the user's version of Windows and security settings it won't be possible to detect/access all window stations and desktops.
Attached Files
Viewing all 1539 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>