Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all 21198 articles
Browse latest View live

How many programming communities have closed down? Source website closed

$
0
0
3.63 million programming source materials united development network-pudn.com

http://www.pudn.com/

Upon receiving a request from the Office of the Cyberspace Administration of China, this site contains illegal information and needs to be rectified. The login and registration are temporarily suspended, or this site may be permanently closed
VB network, source site, one by one, VBGOOD is also dead, CSDN is also dead

Please inform each other of the contact information of the webmaster so that the refund can be processed.
This site was established in 1998 (it started as a programming salon). After more than 20 years, it may be time to quit. If you want to download the source code in the future, you can go to github or search from Baidu by yourself.

Maybe the author will give you a batch of source code, buy the source code of VB6 for very little money, or ask for free gift, this is also the wealth of society.

who want to buy?

Integrate Node.js to VB6 (or RC6)

$
0
0
There are many excellent libs on the Internet that are written in JavaScript or TypeScript, but it is difficult for us to use these libs directly in VB6, because the default running environment of these code libs is Node.js, not Web-Browser.

I'd like to know if it is possible to integrate Node.js into VB6 (or RC6), just like RC6 WebView2-Binding (Edge-Chromium).

In this way, I can call Node.js in VB6 to easily execute some JavaScript libs or TypeScript libs, for example:

Code:

sScript = "var esprima = require('esprima');" & _
            "var program = 'const answer = 42';" & -
            "esprima.tokenize(program);"

vbNodeJS.Start

sResult = vbNodeJS.ExecuteScript(sScript)

Or

Code:

With vbNodeJS
    .Start

    .Cmd "var esprima = require('esprima');"
    .Cmd "var program = 'const answer = 42';"
   
    sResult = .Execute("esprima.tokenize(program);")
End With

Any help and suggestions would be greatly appreciated.

[RESOLVED] Need help with flexgrid

$
0
0
Hello vbforums
I have a table like this
ID---------- Item
1 ---------- aaa
1-----------bbb
Code:

Select* from Tbl where ID=1 group BY ID, Item"
Do While Not Rs.EOF
Text1.Text = Text1.Text & "  " & Rs!Item
Rs.MoveNext
Loop

I get this :

aaa bbb

I want to sort them the same way but in Flexgrid.

Code:

Rs.MoveLast
 Rs.MoveFirst
With Me.VBFlexGrid1
Do While Not Rs.EOF
.TextMatrix(i, 1) = Rs!ID
.TextMatrix(i, 2) = Rs!Item
Rs.MoveNext
If Rs.EOF = False Then
i = i + 1
End If
Loop
End With

The output is:

ID---------- Item
1 ---------- aaa
1-----------bbb

But I need this output:

ID ---- Item
1 ------ aaa bbb

Thank you

Vb6 res file size error?DWord Alignment of VB Resource File Entries

$
0
0
I put the DLL and OCX into the resource file, which can be loaded without decompressing it to the hard disk, but the file size was mistaken by the compiler. As a result, the DLL cannot be loaded in the memory.

I PUT A FILE TO Res file,
size=377093
dim bt2() as byte
BT2 = LoadResData(ResNameOrId, ResGroup)

ubound(bt2)+1=377096

Why is it adding 3 bytes? It’s so weird
===================
Other people on the Internet have also encountered this problem:
When you plan to add a text file to the resource file and release it while the program is running, you will definitely think of using the resource editor. Okay, the program is ready, load the text file with the byte array loadresdata, and then use open/ Put/close or use API to write this text file to the hard disk, press F5 to run, open the text file to see, uh, no problem, ok, compile the program to EXE, then run it again, open the text file to check, uh , Still the original content.

Many people will think that the program is normal when they see this. In fact, you can use the HEX editor (ULTRA EDIT or other) to compare the text file generated by running in the IDE environment and the text file generated by running after compilation, you will find There are 2 more bytes (00 00) at the end of the text file generated after compilation. These two bytes will not have a big impact on general text files, but for files like XML that need to be strictly interpreted , Two more unnecessary bytes is a fatal injury.

Wonder, how did these two bytes come into being? Analyze the process of file generation:

First look at the results of running under the IDE

The first is loadresdata to load the text file data in the resource file into a byte array

Will there be a problem here? Run in the IDE, set the interrupt, check the value of ubound (byte array), and find that it is the same as the original number of bytes in the text file, so it is excluded from the loading process

Then output the file through VB's own file writing statement or API function

Run in IDE, use OPEN/PUT/CLOSE and CREATEFILE/WRITEFILE/CLOSEHANDLE to generate files. Normally, they are the same as the original file bytes, so it can also be excluded.

Then look at the result of running the compiled EXE file

The same is to loadresdata first to load the text file data in the resource file into a byte array

You can’t see the result here. You can set a msgbox prompt ubound (byte array) value in the program. You can see that the array is 2 bytes more than in the IDE. I can’t explain whether there is a problem here, and continue.

Then output the file through VB's own file writing statement or API function

After inspection, the files are more than 2 bytes, eliminating the possibility of function errors

So where is the problem? Keep watching

Then use PE explorer to check the internal resources of the EXE file, you can find the text file we put into the resource file, we select this resource, and then click the resource property to view the size of the resource, the shortcut key is (shift+ctrl+P), you can see The number of bytes displayed is 2 bytes larger than the original file. It turns out that the culprit we are looking for is here. It is already so big. No wonder the output will be larger than the original file. The function is not wrong. The function is just for you to output honestly, or from the resource The data coming out of the file doesn't have to be messed up, so why is the IDE output correct, but the EXE output is wrong? It is because the EXE has been compiled and the resource files are compiled into the EXE file. The problem lies in the compiler. The text files in the EXE resource files that are handed out by it are all 2 bytes larger. As for why there are any Conclusion, waiting for the master to answer us. However, it's better to come out and give us a lecture, and send us a new compiler by the way.

API For StrConv(Block, vbUnicode),MultiByteToWideChar(GetACP

$
0
0
StrConv(Block, vbUnicode),Frequently prompts memory overflow for no reason。

ByteToUnicodeStr Under normal circumstances, it will run 30-50% faster than StrConv (Block, vbUnicode)

how to call by api?
ByteToUnicodeStr = Left$(ByteToUnicodeStr, lngResult)
This sentence will also cause :String space overflow

Code:

Public Function ByteToUnicodeStr(lPtr As Long) As String 'good,快44%
    Dim lngUtf8Size As Long, lngResult  As Long
    lngUtf8Size = lstrlenA(lPtr)
'    ByteToUnicodeStr = StringHelpers.SysAllocStringLen(ByVal 0&, lngUtf8Size) '  '47.65%
ByteToUnicodeStr =string(lngUtf8Size," ")
    lngResult = MultiByteToWideChar(GetACP, 0, lPtr, lngUtf8Size _
    , StrPtr(ByteToUnicodeStr), lngUtf8Size)
    ByteToUnicodeStr = Left$(ByteToUnicodeStr, lngResult)
End Function



Classic VB - Does Visual Basic 6 support Unicode?-VBForums
https://www.vbforums.com/showthread....upport-Unicode

Reading and Writing UTF-16 and UTF-8 Files-VBForums
https://www.vbforums.com/showthread....nd-UTF-8-Files

Treeview CC version 5 error 360 'Object already loaded'

$
0
0
I'm using Treeview from Common Controls version 5 because it can be themed.
I have SP6 installed.

I found a weird bug:

If the project is opened directly when you start the IDE it works fine, but if you first open other project, or even a blank new project, and after that you open the project that uses the Treeview, when you try to access any property of the control it raises the error 360 'Object already loaded'.

Easy to test:

Code:

Private Sub Command1_Click()
    TreeView1.Visible = False
End Sub

Attached Files

[vb6] mimic windows 3.11 gui project

$
0
0
hello everyone as well as you know i'm fanatic for imitating windows gui for fun and free for the guys to use and edit as the only thing i ask is that if a relevant modification is made be shared, but then i made many of these systems with vb.net but I decided to migrate to vb6 because it does not need .NET so any windows pc can run our mini 32bits interface I want to deploy in the list view the pattern below displaying icons and name as I did in windows 1.0 listing files from the directories.

Name:  windows31-01-11344007.jpg
Views: 14
Size:  39.4 KB




So creating not only the desktop but also the file explorer well I already started the project and configured some things and put it to appear listing files for a txt but that would be bad and slow so I removed it so I thought about using listview with icons but in windows format 3.11


does anyone have an idea or light for this to list files with an icon on top and a name on the bottom of the icon

See My program:
https://imgur.com/a/VwxuNCZ
Attached Images
 

Problems with combo boxes

$
0
0
I have two problems with comboboxes:

Problem 1:
I have found a very good webpage regarding VB6 combo boxes:
https://www.thevbprogrammer.com/Ch09...Comboboxes.htm
In there, one of the examples is called: "Extend the Number of Items Displayed"

Here is how it works:
Code:

Option Explicit

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

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 Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Const CB_GETITEMHEIGHT      As Long = &H154

Code:

Public Sub SetDropDownHeight(pobjForm As Form, _
                            pobjCombo As ComboBox, _
                            plngNumItemsToDisplay As Long)

    Dim pt              As POINTAPI
    Dim rc              As RECT
    Dim lngSavedWidth  As Long
    Dim lngNewHeight    As Long
    Dim lngOldScaleMode As Long
    Dim lngItemHeight  As Long

    lngSavedWidth = pobjCombo.Width

    lngOldScaleMode = pobjForm.ScaleMode
    pobjForm.ScaleMode = vbPixels
   
    lngItemHeight = SendMessage(pobjCombo.hwnd, CB_GETITEMHEIGHT, 0, ByVal 0)
   
    lngNewHeight = lngItemHeight * (plngNumItemsToDisplay + 2)
   
    Call GetWindowRect(pobjCombo.hwnd, rc)
    pt.X = rc.Left
    pt.Y = rc.Top
   
    Call ScreenToClient(pobjForm.hwnd, pt)
   
    Call MoveWindow(pobjCombo.hwnd, pt.X, pt.Y, pobjCombo.Height, lngNewHeight, True)
   
    pobjForm.ScaleMode = lngOldScaleMode
    pobjCombo.Width = lngSavedWidth

End Sub

If I put a combobox on a form, and use that procedure like this:
Code:

  SetDropDownHeight Me, Combo1, 20
It will work perfectly.

But, the problem is that my combobox is not DIRECTLY on a form.
It is on a picturebox.
And that is why the above procedure doesn't work.

I need to tweak the above procedure, such that it would work for a combobox whether located on the form or on a picturebox.
But, I don't know how to do that.
Can you please help?


Problem 2:
I have a number of comboboxes that are located at the far right of a form.
The width of the contents of the dropdown boxes are larger than the width of the comboboxes themselves.
So, when at runtime, I drop the combobox, the contents of the combobox (that are wider than the un-dropped combo box) extend beyond the right side of the application.
And if the application is positioned at the far right of the screen (monitor), then the contents of the dropdown box are cut off at that point.

I need to force the combobox to show its contents as "right-aligned with the combo box itself.
They are currently left-aligned, and that is why they exceed (and sometimes are cut off at) the right border.

I don't know how to do this.
Can you please help.

Thanks.

Optimization bug in vb6

$
0
0
I tried to execute this piece of code:
Code:


Private Sub Form_Load()
 Dim a As Integer, b As Integer
  a = &H8000  ' INT_MIN
  b = a + 1      '  b = a -1 is obvious underflow!
  b = b - a
End Sub

- vb6 IDE (OK)
- vb6 exe (No optimization) (OK)
- vb6 exe (p-code) (OK)
- vb6 exe (Optimize for Fast Code and checked "Remove Integer Overflow Checks") (OK)

- vb6 exe (Optimize for Fast Code) reports the error "Overflow" ???
- Changing &H8000 to -32768 and optimization is on (OK) ???
- Changing &H8000 to &H80000000 and declaring a as Long, b as Long has the same effect
- b = a + 2 has the same effect

Any logical explanation?

By the way, this code:
Code:


Private Sub Form_Load()
 Dim a As Integer, b As Integer
  a = &H7FFF
  b = a - 1
  b = b - a
End Sub

works fine.

System information:
OS: Microsoft Windows 7 Professional 32 bit
VB Version: 6.1.7601 Service Pack 1 Build 7601

list1 how to sum the 5 column

$
0
0
Hi, I'm ontro

I can't sum the 5 column of list1


I have the code in excel that does it well
How would the code be in vb 6.0, thanks


the code in excel is the following


Code:


Dim I As Integer
Dim Sum As Double

Sum = 0
    For I = 0 To ListBox1.ListCount - 1
   
        Sum = Sum + ListBox1.List(I, 4)'Column 5

    Next I
            TextBox2.Text = Sum


how would the code be in vb 6.0

Thank you

If there a component just like the Excel spreadsheet but not the FarPoint Spread

$
0
0
hi, everybody :

I think the component should be add functions or references in cells.

Export text to a web page

$
0
0
Hello my friends
Please Help
What is required for this code to work is to export text to the web

HTML Code:

Private Sub Command1_Click()
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
 
objIE.Visible = True
  objIE.navigate App.Path & "\page2.htm"
 objIE.document.getElementById("T1").Value = "blah blah"
End Sub

:blush:

Textbox Control

$
0
0
Hi On a form I have 22 textbox's all of them have the enabled property set to false can I
change 12 textbox's enabled to true in a similar way as my example The textbox's are in a Array txtSum()
Code:

VB6

Dim Ctl As Control

    For Each Ctl In frmBalPosts.Controls
        If TypeOf Ctl Is TextBox Then
          Ctl.Text = vbNullString
          Ctl.Enabled = False
        End If
    Next

Thank you

Thinfinity UI

$
0
0
Hey people. I'm playing around with the Thinfinity UI which is a commercial product. It's supposed to allow you to publish your VB6 program to the web with 1 line of code. And weirdly enough it really does work! But there's a catch... isn't there always.

When I reference the Thinfinity UI in my project, it no longer compiles. The compiler barfs on word Error$ inside my error trap with this message: Type=declaration character does not match declared data type

If I remove the word Error$ or change it to Error then the project compiles. Problem is Error comes up as 99 regardless of the error.

I'm assuming their code somehow redefines the reserved VB6 word Error$ as an Int or something like that.

Sadly the people at Cybelsoft say they are unable to reproduce the issue and everything compiles fine and aren't too interested in digging deeper.

They do have a lot of customers and claim I'm the only one who's having this issue. Any idea if there's anything I can do on my end or any error I might be making?

Name:  compile.jpg
Views: 50
Size:  24.6 KB
Attached Images
 

Change “Open For Binary Access” with Private Types to something with Unicode support

$
0
0
Hi,

I’m looking for some support/suggestions on transitioning my “Open … For Binary Access” approach, to one that supports Unicode characters in path and filename.

One of the features in my app saves data plus a thumbnail in a binary file using the following code:

Code:

Dim PPB As New PropertyBag
Dim oStdPicture As stdPicture
Dim lFileNumber As Long

lFileNumber = FreeFile
Open sFullFileName For Binary Access Write As #lFileNumber

Put #lFileNumber, 1, MyPrivateType1
Set oStdPicture = frmMain.picCanvas.Image
PPB.WriteProperty ("Picture"), oStdPicture
Put #lFileNumber, , PPB.Contents
Put #lFileNumber, , MyPrivateType2

Close #lFileNumber

(To simplify the code, I’ve left out the definition and population of the private types.)

Then, to read the data from the file, it’s using this code:

Code:

Dim PPB As New PropertyBag
Dim oStdPicture As stdPicture
Dim lFileNumber As Long

lFileHandle = FreeFile       
Open sPath & sFile For Binary Access Read As #lFileHandle

Get #lFileHandle, 1, MyPrivateType1
Get #lFileHandle, , varBlob
PPB.Contents = varBlob
Set oStdPicture = PPB.ReadProperty(("Picture"), Nothing)
Get #lFileHandle, , MyPrivateType2

Close #lFileNumber

As part of making my app fully “Unicode aware”, I realized that the “Open … For Binary Access” function, doesn’t support e.g. Thai or Russian characters in the filename or path if you’re running e.g. an English Windows.

For other parts of the app I’m using the ADODB Stream to load the full file in memory, and then process it line by line, but I have no idea how to deal with the Private Types and thumbnail blob in this case.

All suggestions are welcome and much appreciated!

Thanks,
Erwin

Cannot Register vbzip11.dll

$
0
0
Dear all,

Recently, I have a problem when setup the software that will use vbaccelerator vbzip11.dll. The problem is when I try to register the vbzip11.dll then it appear the DllRegisterServer is not found. I remember that when I try to register the dll serval years before that without any problem.

Please help! Thank you so much!

Steven

how to zorder controls? move top,move up

$
0
0
How to write the code of the visual sequence adjustment tool

I am developing a visual form designer, how to adjust the order of the controls arbitrarily, and encountered a problem in this regard. I uploaded the example Prj_ZorderSet.zip, which can be modified above

want Move Picture 1 behind Picture 3
Change 1 No. 3
Actual display
Figure 2, 3, 1

And put number 2 behind number 5.
Actually becomes 3,1,4,5,2

How to write the code of the visual sequence adjustment tool?

Name:  Zorder Set Tool.jpg
Views: 35
Size:  35.3 KB
Name:  Visual FormEdit.jpg
Views: 30
Size:  36.9 KB
Attached Images
  
Attached Files

Frustrating and Inaccurate Arithmetic calculator program

$
0
0
Hi! I am making an Arithmetic calculator using VB 6.0 and I wonder why the result is not accurate.

See, I am inputting 1 on Common Difference, 1 on Initial Term, and 100 on Term Interval. Now its result is 5,050 on the program but when it comes to 1, 1, and 6, its result is 1 now why is that?

here is the code:

Code:

Option Explicit
Private Sub btCalc_Click()
    Dim A As Double
    Dim N As Double
    Dim D As Double
    Dim R As Double
    Dim F As Double
   
    A = GetFrac(txtInitterm.Text)
    N = GetFrac(txtTermint.Text)
    D = GetFrac(txtFinterm.Text)
    R = GetFrac(txtTermint.Text)
   
    F = N / 2 * (2 * A + (N - 1) * D)
   
    lblOutput.Caption = F
   
End Sub

[VBDOS] Visual Basic For MSDOS Max power of this

$
0
0
Hello everyone, I know it's been a long time and the syntax has changed from vb6 to vbdos but I'm just going to ask people to play with what would be really cool, I would like to know the maximum power of VBDos since nowadays we don't find many things about him.

Example:
The graph of it can be changed to look like windows 3.11 or 1.0?

It can import fonts and files to change text?

it is possible to insert a pcx image in the picture box i have never heard of?

listview is possible too use it ?

importing libraries with vbdos has how to import data and libraries dll windows 1.0 ?

there is some other version of vbdos created by users based on visual basic 2.0 or 3.0 because there were rumors that microsoft was going to release a version 2 of vbdos and gave up , exists another ?

in addition to the run function there is another one that calls another form or .exe so that it overlaps the other form it called as in windows, giving the call to several forms or .exe ?

are curiosities that I always had about visual basic 1.0 for msdos regardless of whether it is a pro version or just the common version.

If there is a digital book or pdf about it I am also interested.

Auto incremented number doesn't change for all rows after being deleted from listview

$
0
0
I have one auto increment number in listview which is not connected to database as I have being adding sales items in it through a button and also 2 more buttons for editing and deleting. My problem is that when I delete a row the auto increment number does not change for all the remaining rows. Please suggest a solution. My code is in vb6.0.
Code:

        If listview1.selecteditem is nothing then Exit Sub
          Listview1. Listitems.Remove listview1. Selecteditem.Index
End sub

Viewing all 21198 articles
Browse latest View live


Latest Images

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