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

Invalid use of Me


Convert from vb.net to vb6

$
0
0
Hi I have small program in vb.net I am trying to convert to vb6 code
Can anyone help me with this?

Code:

Imports System
Imports Microsoft.VisualBasic
                               
Public Module Module1
        'Xor all the binary digits of 'input'.
        Public Function Parity(input As Integer) As Integer
                Dim output As Integer = 0
                While input <> 0
                        output = output Xor (input And 1)
                        input = input >> 1
                End While
                Return output
        End Function
       
        'Move the 2 least significant bits into the most significant positions.
        'Assume the input is 16 bits long (i.e. 4 hexadecimal digits).
        Public Function LeftRotateBy2(input As Integer) As Integer
                Return ((input And 3)<<14) Or (input>>2)
        End Function
       
        'Convert 'input' into a 'numDigits' digit hexadecimal string
        Public Function ConvertToHex(input As Integer, numDigits As Integer) As String
                Dim hexDigits As String = "0123456789ABCDEF"
                Dim output As String = ""
                For i As Integer = 1 To numDigits
                        output = Mid(hexDigits, (input And 15)+1, 1) & output
                        input = input >> 4
                Next
                Return output
        End Function
       
        'Create table
        Public Sub Main()
                Dim result As Integer
                Dim resultHiDigits, resultLoDigits As Integer
                For n As Integer = 0 To 255
                        result = LeftRotateBy2((Parity(n)*7<<8) Xor n Xor (n<<1))
                        'Split result into two
                        resultHiDigits = result>>8
                        resultLoDigits = result And 255
                        'Display result as two 2 digit hexadecimal numbers
                        Console.WriteLine("{0,3} : {1} {2}", n,
                                ConvertToHex(resultHiDigits, 2),
                                ConvertToHex(resultLoDigits, 2))
                Next
        End Sub
End Module

[RESOLVED] Message error run-time

$
0
0
Hello VBForums
Hello evey one
Please Gentelmans
If you can help to resolve my problem
In my projet i have Form1 with command11 only for display a page ActiveReport1
When i click on this command11 for the first time i can see ActiveReport1 and it works very well
But if i close ActiveReport1 and i click command11 for second time to display this ActiveReport1 I receive an error message
Run-Time Error #438:
Object doesn't support this property or method
ActiveReport1.DataControl1.Recordset=rs.Clone
Than you in advance for help
Cordially
MADA BLACK

Any way to suppress the "Automation Type Unsupported" error

$
0
0
This is probably a question for The Trick, but I'm certainly willing to read ideas from anyone.

Okay, what am I talking about? I'm talking about using the VariantChangeTypeEx call, and specifying any of VT_UI2, VT_UI4, VT_UI8, or VT_I1. If you do this, and then subsequently do any math with the numbers, you'll get this Automation Type Unsupported error.

I'm not entirely clear on whether this math is getting done in oleaut32.dll or possibly somewhere else. However, it's clear that it can be done. It just seems that VB6 is leary about doing it. I'm just wondering if there's some way to suppress the error, and have VB6 go ahead and do it. Trick, I mention your name because you've already done something similar with your Advanced Tools, and you also have incredible knowledge about some of the darkest corners of VB6.

Also, just to mention it, the LongLong type (VT_I8) works fine so long as it's ByVal in the Variant. If it's ByRef in the Variant, it also throws this Automation Type Unsupported error.

Also, here's a cross-reference between VB6, VBA, PROPVARIANT, and .NET:

Code:

VB6            VBA        PropVar    .NET

Byte            Byte        VT_UI1      Byte
n/a            n/a        VT_UI2      UShort
n/a            n/a        VT_UI4      UInteger
n/a            n/a        VT_UI8      ULong
n/a            n/a        VT_I1      SByte
Integer        Integer    VT_I2      Short
Long            Long        VT_I4      Integer
in Variant      LongLong    VT_I8      Long

And, when in a Variant, they can be either
ByVal (in the Variant) or ByRef (Variant points to).

It'd just be nice if we (VB6 coders) could have access to all of these types, with full in-line math support.

Thanks,
Elroy

How do you properly receive TCP data?

$
0
0
Each time the Winsock control receives a chunk of data over the network, the DataArrival event is fired. However, with the TCP protocol, there is no guarenty that the entirety of the data that was sent, will arrive in in a single firing of the DataArrival event. In other words. There's no guarenty that the entire chunk of data that was sent will arrive at its destination as one chunk. It could end up being split into multiples smaller chunks. In fact, it could arrive with one byte of data in each chunk. Likewise, multiple chunks sent in rapid succession from the sending computer, may actually arrive at the destination as a single large chunk composed of all the data of the smaller chunks concatenated together. Or some combination of these could happen. For example, 5 chunks of data being sent from the sending computer, could end up at the receiving computer as 2 chunks, each with two and a half times the amount of data that would fit into a single sent chunk (or maybe it would be split 2 and 3 instead of 2.5 and 2.5).

And the recieving computer must deal with ALL of these situations. It can't assume ANYTHING about the amount of data in each chunk. It can't even receive the first 4 bytes of the total data being sent (if that contained a byte count for the rest of the data) and then wait until that many bytes is received, because that first 4 bytes could get split between multiple chunks (though that is unlikely for such a small amount of data as a 4 bytes, the receiving computer MUST be able to handle the situation in which such a splitting occurs).

So what is the best way to make sure that the DataArrival event if the Winsock control can properly handle any situation of chunk splitting when receiving data over a TCP connection?

With UDP it's different, each chunk of data sent is guarantied to be one chunk of data at the receiver. However, with UDP there is no guaranty that the data will ever reach the receiving computer (especially when the size of the chunk is several thousand bytes long), which is why TCP is better for sending large amounts of data. Though with TCP you have the entire thing involving chunk splitting and concatenating that means there's no way to guaranty that the data chunks will arrive at the receiver in the same size and number as those that were sent. So I need to figure out the best way to handle this such splitting and concatenating of chunks which can occur at any point in the network or internet (every device like routers that the data passes through may end up splitting or concatenating the data chunks).

Command button Properties

$
0
0
Hi,

I see a Back Color property but it doesn't seem to work... and no fore color property.

Not a biggie, but in Win10 it's hard to tell when the button is enabled. Anyone have any ideas? Thanks

[Resolved] Highlight second last line of a RichTextBox

$
0
0
G'day,

My app reads error log files of another app which displays the error name on the last line of text.
I can highlight the last line of a RichTextBox however in this case the other app adds a blank line leaving me without any seltext.

I can align the cursor at the end of the text by using ...
Code:

SendKeys "^{backspace}"
but that's a bit "iffy" (especially if the user double-clicks) and I don't know how to highlight it from there.

Your help in solving this would be appreciates. Cheers.

Implmenting a class that contains Implements

$
0
0
In VB6 can you implement a class which contains other implements?

For example, I have a class called clsIScript which is implemented in a Form called frmEdit. In clsIScript, I want to implement IDrectEventSubscriber.

When I try this I get the message:

---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Object module needs to implement 'clsIDirectEventSubscriber_SetStatusVisibility' for interface 'clsIScript'
---------------------------
OK Help
---------------------------

I've tried it a couple ways syntactically (adding what it asks for directly with the method name, using the implements keyword for the DirectEventSubScriber myself in the frmEdit class, pretending the name like clsIScript_clsIDirectEventSubScriber_SetStatusVisibility) but none seems to satisfy this message.

Just wondering if there is some trick or is this too deep down the rabbit hole.

Thanks!

In the IDE, detecting design-time vs run-time

$
0
0
Hmmm, this is a curious one I haven't needed before. While in the IDE, I need to figure out when I'm in design-time versus run-time.

You may ask, why would you need to know this? Or, no code is running in design-time, so what difference does it make?

Well, it's not true that no code is running. Specifically, code is running in custom UserControls.

You may now ask, why don't you just use the Ambient.UserMode property of the UserControl. However, that property isn't always available (which is precisely my problem).

Here's another way to think about it: What can I type in the Immediate window that tells me design-time versus run-time?

It seems like there should be an obvious answer, but it's not coming to me.

Thanks,
Elroy

Clear code

$
0
0
Hi

How to remove all variables and routines that are not being used


Is there any tool or way to do this?


TIA

issue with vb 6.0 program under windows 7

$
0
0
i have issue running vb 6.0 program under windows 7
it runs okay with windows xp
when i run setup it gives access violation occured while registeration dao350.dll and does not copy some files too.

the software is about weigh bridge slip print
the print slips has some black strip under amount tag under windows 7. but in xp its okay
currently iam using virtual box to run xp under windows 7.
can somebody help me run the software under windows 7>
the username is a and password is a.
u have to copy it under C:\almurtaza\data\scale.mdb to run it.

Running IDE in SxS mode with external manifest

$
0
0
Does anybody do this? (Run the IDE in SxS mode with a manifest.)

I'm considering doing it to get away from any requirement to register my OCX files, even during development.

I'm just wondering if I'm walking into any trouble of which I'm not currently aware.

Just as an FYI, I've been running my projects in SxS for years, and never had any problems with that.

Also, I'm assuming I'd just place a VB6.exe.manifest file in my "C:\Program Files (x86)\Microsoft Visual Studio\VB98" folder and then I'd be all set.

Regards,
Elroy

open Recording devices window

$
0
0
how to open Recording devices window by code?? windows 7
i need to change stereo mix and mic quick
Attached Images
 

Measuring mains frequency

$
0
0
Has anyone ever written a program in vb6 to measure mains frequency? And if so, how did they arrange the interface (possibly via a capacitively coupled LV transformer connected to either the serial port or USB?)

How to register WinSCP dll or library in VB6

$
0
0
I am unable to register WinSCPnet.dll in VB6, it always throws error when i try to register.
I am new to vb6, so i am not sure how to register it. The more i google, i become more confused.
I am registering this dll because i need to convert FTP code to SFTP in VB6.
This dll has something to do with WinSCP COM object also, i am not sure if i need to register this also.

How to extract image from DVR

$
0
0
Hi

I have HIKVision Camera installed connected to DVR through Cable. I want to extract image at that particular time when user Clicks button in Software. How it can be done . What information i need about DVR.

Thanks

VB 5 CCE compiler package

$
0
0
Am a retired electronics engineer, and to keep my mind active, I am looking for the old VB 5 CCE Microsoft compiler complete package. Looking for a free download link that is good and still active. I have lots of old VB 5 files and want to rebirth them, dust them off so to speak and move them to newer versions of VB. Can somebody provide me with free download links, or other assistance in order to obtain the complete package. Thanks in advance.:wave:
Regards, royski45

Attempt to open a database exclusively

$
0
0
Hello VBForums
Hello every one
Please gentelmans if you can help me to resolve this problem
For three days day and night ..i tried to put DB.close .. i make US.close .. i make RS.close ..everywhere but unfortunately I have not succeeded
I have a code for Login and logout in Form1:
Code:

Sub LOAD_Numero_Automatique()
Call ConnectionDatabase
If US.State = adStateOpen Then US.Close
US.Open "[UsermanLog]", DB, adOpenStatic, adLockOptimistic
max_Numero = US.RecordCount
If max_Numero = 0 Then
Text1.Text = Val(1)
Else
Text1.Text = Val(max_Numero) + 1
End If
End Sub

In Form1 Load i put :
Call LOAD_Numero_Automatique
In Form2 i have a code for Backup DataBase.
If i erase in Form1 Load ( Call LOAD_Numero_Automatique ) then in Form2 i can Backup DataBase and it works very well
But if I leave in Form1 Load ( Call LOAD_Numero_Automatique ) and I want to Backup DataBase then its blocks with an error message : Run Time error 3356
You attempted to open a database that is already opened exclusively by user 'admin' on machine ....
If I only delete the line in form1_load the Backup it works very well
I can not delete this line since it has a relation with Login Logout
Please how to avoid this message
Cordially
MADA BLACK

GDIPLUS: how rotate an image by a center?

$
0
0
i'm trying rotate an image by zero origin(center), but without lock :(
Code:

GdipDeleteGraphics hGraphics
        GdipCreateFromHDC GetWindowDC(GetForegroundWindow()), hGraphics
       
        GdipTranslateWorldTransform hGraphics, CSng(730 / 2) - CSng(lngwidth / 2), CSng(311 / 2) - CSng(lngheight / 2), MatrixOrderAppend
        GdipRotateWorldTransform hGraphics, 75!, MatrixOrderPrepend
        GdipDrawImageRectRect hGraphics, HBITMAP, 100, 100, lngwidth, lngheight, 0, 0, lngwidth, lngheight, UnitPixel, ImageAttributes
        GdipDisposeImageAttributes ImageAttributes

the image is drawed on 75 degrees. but not using the center :(
so what i'm doing wrong with GdipTranslateWorldTransform() for use a center?

the 730X311 is the form size(WXH). hGraphics is from form hdc.

[RESOLVED] Delete a key or subkey from register

$
0
0
hi all
I tested tons of codes trying to delete a key or a subkey from the register but I failed.
I'm saving the login information under this key.
My Computer\HKEY_Current_User\Software\VB and VBA Program
And I want to give the user the option to make free accession to the application.
Thus the only way to do so is deleting this key.
this is what I need to delete.

Name:  111.png
Views: 31
Size:  2.2 KB

Is there somethig simple and easy that I can manage.
thanks in advance.
Attached Images
 
Viewing all 22043 articles
Browse latest View live


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