FAQ Database Discussion Community

Is there a variable type which can refer to a control (type may differ) in vb6?

I have two controls which both serve the same function with different data sources (Access vs SQL) in a legacy vb6 application. I am trying to create a variable which refers to the control which is applicable to that data source (In this case, an ssOleDBCombo vs an SSDBCombo). Is...

Why do I have to register COM DLLs using regasm?

I have created a COM DLL with VB.NET. It has COMVisible = true, and using its TLB file, I can use this DLL in VB6. On test machines, I can only use the COM DLL in a VB6 application after it has been registered using regasm.exe. Does anybody know why...

Change DataGrid cell value in VB6

Good day guys. I am developing VB6 project and I know it's old but thats the standard in Japan. I am not into datagrid expert guy that can tweak everything inside of it but my problem is that I have data to be displayed in datagridview which they want to...

COM Class on a destination machine

I followed this http://support.microsoft.com/kb/817248 tutorial to make a .NET COM class for my vb6 project to be able to access. I added it through references but what it adds is the testproj.tlb file and not the testproj.dll. It works fine on my development machine. However I took the compiled .exe...

Memory consumption by two dimensional array of strings and msflexgrid

Two dimensional array of string takes 2 times more memory than msflexgrid with same text, how? Is there any other efficient method in vb6 to save string ?

GetWindowsDirectory() API returns wrong (vba\vb6)

on my Windows-Terminal user, I'm trying to have two application point to the same Windows directory, one written in VBA one in VB6. When calling the GetWindowsDirectory() API from VB6 it returns the correct path C:\documents and settings\%user%\Windows When calling it from VBA macro, it returns C:\Windows Notice that same...

Code difference between the two times

I need help with code vb6 I need code like this t1.text=now ' example "10:30:00 PM" t2.text="1:00:00 am" ' that next day and i can chang him t3.text=t2.text-t1.text ' he most be "2:30:00"and Countdown 'and i need code to + hour amd minute ' example 't2.text is "1:00:00" + new...

Convert 10009335357561071 to hex string

Public Function MyMod(a As Double, b As Double) As Double MyMod = a - Int(a / b) * b End Function This code doesn't work as it doesn't correctly show the remainder do be able to then calculate HEX. Correct : 10009335357561071 / 16 = 62558345984756.69 VB6 MyMod returns 0...

Storing matrices in an array in visual basic 6

I am new to vb6 programming and i have the following problem. I am computing some 2x2 matrices inside a for loop and i want to store these matrices in an array. To be more precise i want to know if there is something like the cell array in Matlab....

I want to give validation for mobile number in vb6

I give validation for mobile number but I want mobile number should start with 7,8,9 digits.I want to give validation that mobile number should start with 7,8,9 digits only. If Len(TextBox11.Text) < 10 Or Len(TextBox11.Text) > 10 Then MsgBox("Enter the phone number in 10 digits!", vbExclamation, "") This code is...

How to solve code conversion issue?

Public Function SaveCommentsTreeComments(ByRef f As System.Windows.Forms.Form) As Integer Dim IsNewSubComment As Boolean Dim IsNewCommentWithSub As Boolean Dim sql As String Dim rs As New ADODB.Recordset Dim CommentID As Short Dim SubCommentID As Short Dim Index As Short 'WMB 1/28/2004 nextval Dim cSql As String Dim cRs As New ADODB.Recordset Dim...

Invoking a RESTFul WebService using WinHttp

I am totally new with VB6 and REST architecture. Nevertheless I would like please to know if there is any HelloWorld example for a REST Client which invokes a RESTFul webService using Windows HTTP Services API. Many thanks in advance.

Negate a specific group in regular expressions

How do you get a string not containing a specific group? (?:[0-9-+*/()x]|abs|pow|ln|pi|e|a?(sin|cos|tan)h?)+ Above string is the expression for mathematical expressions. How do you get the string that is not a mathematical expression? Example:WIDTH+LENGTH*abs(2) Supposed Output: WIDTH LENGTH...

How to decode UTF8 in VB6?

I was just wondering if anyone has decoded UTF-8 in VB6? I am having a problem where ANSI 127 and greater are not being properly decoded for whatever reason. For instance Ä gets decoded into à and I'm not sure why....

vb6 can not connect oracle 11g r2 with ADO but can connect with SQL Developer

I can not connect Oracle 11g r2 with ADO in VB6. But I can connect Oracle database with Oracle SQL Developer with same parameter. How do I check this problem? Here my connection string: (The password is hide) connstr = "Provider=OraOLEDB.Oracle;dbq=[same name]:1521/[same name];Database=[same name];User Id=evo;Password=*****;" and this parameter in SQL...

Switching from ODBC to OLEDB and getting “Object Required”

I have been tasked with modifying some VBA code to switch from using an ODBC connection to using an OLEDB connection so we can just code a username and password into a subroutine. I'm certainly not experienced with this but I think I'm managed to get the proper connection string...

If Statement Contains Only “True”

I am converting a vb6 app into c# and I've come across something I don't quite understand. I've never seen an if statement structure where the expression being evaluated is literally "true" or "false". private bool InitializeForProgramming() //OK { if (J1939.getReplyStatus() == modJ1939.dmOpFailed) //or OpComplete (dmBusy auto cycles) { //check...

How to preview a VB6 .frm file?

I have an old VB6 project that is still alive and needs some attention at the moment, but I don't know anything about VB6 and I am just wondering how to preview a .frm file from the project. I also have the .vbp file if that could be of any...

CryptAcquireContext() fails with return code 0x8009000B NTE_BAD_KEY_STATE - But user password has not changed

My company has a program compiled in vb6 which requires an encrypted license code to be validated before the software can be used. Recently, a client called saying the license code was failing to validate and the program was locked. After some investigation, I discovered the code was failing on...

Multi-res Icon use in VB6

I have some multi-res icons containing 32x32, 48x48, and 128x128 versions. Currently, when assigning an icon to a button, it uses the 48x48 version because it's the first in the stack. Since automatic resizing functions are ran when the resolution changes or if the screen rotates, sometimes it would be...

How to give file path to “save as” window using vb6

I'm working on a VB6 code. It has to perform the following operations in sequence: 1. Check the window is open or not (Done! using FindWindows) 2. Press Ctrl + S (Done! using SendKeys("^S") 3. Type full path name (Stuck here! Don't know how to proceed) 4. Hit Enter key...

How to reset color properties of Microsoft Heirarchical FlexGrid?

I have an MSHFlexgrid in a legacy VB6 application that the users want to set various colours in. I've sorted out applying the user colours but I need to add a reset option as well. However I'm getting an overflow error when attempting the following line: grdUserData.BackColor = vbWindowBackground The...

Change parameters On error in vb6

I am working with vb6 and automating some tasks to be performed across a large number of spreadsheets. The issue is setting my worksheet. Most of the syntax on the workbooks I am working with is the same however there are some where the sheets have different names. Currently using...

Converting 32x32 StdPicture icons to PNG

I am trying to convert an StdPicture into a PNG before encoding it to Base64 to be sent over XML. I've gotten the Base64 encoding portion down (see near end of function EncodeImageToBase64()) however I am having trouble converting the StdPicture object into a PNG byte array. Here's my function:...

Team Foundation 2012 not recognising changes in vb6 app

I'm using Team Foundation 2012 to provide source control for a VB6 (yes, I know) project. On a newly set up machine (installed Team Explorer 2012 and TFS Power Tools 2012), TFS does not seem to be properly noticing the changes. The local Team Explorer says it is connected to...

How to create an array with textboxes in Visual Basic 6.0

I am working on a very old visual basic project. I have to rewrite the load and save function of the project. Therefore I wanted to create an array of controls which have all relevant textboxes and checkboxes included. I want to iterate through that array to be able to...

Can't get an error in VB6 on Windows 7 while I can on Windows Xp

I must correct some trouble on a program which is made in VB6. When I try to print a file in XPS type and then I close the folder selection box the program give me a "Run time error 482". So I decide to get the error with this :...

ASC Visual Basic for Java

I need a function on Java that do the same as ASC function on Visual Basic. I've had looking for it on internet, but I can't found the solution. The String that I have to know the codes was created on Visual Basic. It's according to ISO 8859-1 and Microsoft...

Dtpicker in VB6

I am able to format my dtpicker using below code. Private Sub Form_Load() DTPicker1.Format = dtpCustom DTPicker1.CustomFormat = "yyyy/MM/dd" DTPicker1.Value = Format(Date, "yyyy/MM/dd") End Sub After get dtpicker value using below code Private Sub Command1_Click() Label34.Caption = DTPicker1.Value End Sub But result is not formatted like as dtpicker displayed value....

How to get a random letter in VB6?

I cannot convert those I see in VB.Net I wanted to create something like a "Word Factory" So I need to produce a random letter. I managed to get a random number using this Dim x, first, last first = 65 last = 90 x = Int((last - Min +...

How to hide the object of the OLE controler?

I'm working with the OLE object using VB6. I use it to play a sound when a certain condition is true. The OLE class is MPlayer. The problem is that I don't want the player to be visible. I know that I can set the Visible property of the OLE...

VB6 Handle error raising in error handler

I have code like this, so when error is raised for the first time (c=1/0) then is going in error handle, after that it going in Again an if there is raised error than app is crashing, not going in error handler, any idea how to fix this? On Error...

Error SQL Command Vb6: Syntax error or access violation

I am programming in VB6. However, I met a problem with execute SQL query in VB6. I try to solve it by searching and learning in Internet, but, I also cannot. Help me please, thank you. This is my code: SqlText = "delete from Student where Subject in (SELECT Subject...

If statement not working in vb6

I want to make a program which could close a window with the title "Personalization" in vb6. The problem is that the if statement is not working.Here's my code(it only finds a window named "Personalization" without closing it): Option Explicit Private Sub Command1_Click() Timer1.Enabled = Not Timer1.Enabled End Sub Private...

Find and Find Next for RichTextBox

richTextBox1.Text = "Where there is a will there is way"; I just want to change the both is only red color. I know how to change the first is, but i don't know how to change the second is. RichTextBox1.SelStart = RichTextBox1.Find("is") RichTextBox1.SelLength = 2 RichTextBox1.SelColor = vbRed ...

Error calling dateadd function

Please help me on this. I run the same code on other computer and they return no error. But on my pc this still pops up. EDIT: Code: Private Sub Form_Load() Msgbox (DateAdd("d",-1,Date)) End Sub Output: Run-time error '5'; Invalid procedure call or argument BTW. The computer I used is...

Reading VB6 three-dimensional array in FreePascal/Lazarus

I wonder how to decode a three-dimensional dynamic array of a custom type written to a binary file in VB6. The custom type is defined as follows: Type XYByte X As Byte Y As Byte End Type It represents two coordinates of a contact point. The three-dimensional array represents pre-computed...

WinHTTPRequest Automation Error (2147024769)

I've recently changed from Winsock to WinHTTPRequest however when this line runs: Set WinHttpReq = New WinHttpRequest I receieve an Automation Error :2147024769. This code works fine on windows7/Windows server 2008, however is failing in Windows 2003. Is this a problem with the winhttp.dll not being found on Windows server...

How to get selected rows in vb6 TDBgrid

I'm a beginner in VB6. I am creating an application that contains a TDBGrid. My problem is how can i get the row selected in this TDBGrid.

Variable Declaration issue in vb6

Well Its been a while that i have had my hands in vb6. I have been declaring variables as dim a,b,c as integer But, today, while writing a program consisting of arrays, the declaration dim ar(10),i,a as integer yielded a wrong result. Then I changed my declaration to dim ar(10)...

Excel Data to Data Grid View in vb6

Hi everybody I am new! So, I was developing a simple software with VB 6.0 (yeah, i know quite old). I had to do is manipulate Ms Excel sheet into VB Application. The actual task is to display the data or tables (whatever we call it)provided in the Excel sheet...

VB5 Project on Jenkins Slave: Build errors

I am attempting to build a VB5 (legacy...I know) project using Jenkins and a Master/Slave configuration. The master checks out the project on the slave then runs a batch file which looks like the following: "C:\Program Files\devstudio\vb\vb5" /make project.vbp The project contains a custom DLL which is registered on the...

VB 6.0 - Formating Textbox “dd/MM/yy”

I've made a question previously about this but I didn't express really what I wanted. I have a textbox that requires the user to write a Date in it. Then he can press a button and generate a report based on the entries on some other textboxes. It is really...

How to convert vb6 'vbFromUnicode' to string in C#

I got as code in VB6, which need to be converted in C#. I have googled it but didn't get any concrete answer. VB code: Dim strTemp = StrConv(strTemp , vbFromUnicode) I tried to do like this in c#: var strTemp = System.Runtime.InteropServices.Marshal.StringToBSTR(strTemp); I think this is not correct. Any...

How to modify this VBA code for VB

I am using this VBA code for covnvert textbox text to regular text. But its through errors on shp.Type and sString = Left(shp.TextFrame.TextRange.Text, _ shp.TextFrame.TextRange.Characters.Count - 1), while i am compiling in VB. What should i change in the code for VB? This is VBA code: Sub ConvertTextBoxToText() Dim shp...

RegSetValueEx returns “Access is denied”, even though regedit allows the same user to edit this value

Our VB6 legacy application calls RegSetValueEx to set a registry value. This registry value can be easily set using regedit. However, when our application tries to set it, RegSetValueEx returns 5 - Access Is Denied. We use the same code to write to other registry keys and everything works fine....

Regular Expression for whole world

First of all, I use C# 4.0 to parse the code of a VB6 application. I have some old VB6 code and about 500+ copies of it. And I use a regular expression to grab all kinds of global variables from the code. The code is described as "Yuck" and...

VB6 get filename from path

In my VB6 code I have the statement Open CommonDialog.FileName For Input As #intFileNum The problem is that CommonDialog.FileName returns an entire path and VB6 Open command needs just a filename. For example if the path is C:\temp\file_name.csv then CommonDialog.FileName will return C:\temp\file_name.csv but this Open statement in VB6 will...

Masking textbox to accept only 1 digit after decimal

I am using VB6 and I want to allow user to enter only one digit after decimal, please help.

Missing responseText Information (vb6 call)

This problem has been driving me crazy, hopefully someone out there knows the answer as I couldn't find one searching around. I am trying to access a web service in one of our legacy vb6 apps with the following: Dim xmlHttpRequest As MSXML2.ServerXMLHTTP Dim xmlParameters As String Dim timeOutValue As...

VB & Chinese string

I am trying to capture a Chinese text from a website using VB6 simple code used to do this as below, working good with the English sites Private Function RequestText(sURL, Optional sMethod = "POST") 'You may have caching issues using GET Dim XMLHTTP Set XMLHTTP = CreateObject("microsoft.XMLHTTP") sMethod = UCase(sMethod)...

Can I open an installed application in visual studio for debugging?

I have an old installed application it is probably a VB6 application that i need to revise and make it a .net but the problem is some computations of quantities are hard to solve. what is your suggestions?

socket opening on WIndows 2012 extremely slow

I'm working on a legacy VB6 app that uses sockets to communicate to various devices. On a 2012 system, we are noticing the time between calling winSock.Connect to the connection event being fired holding at about 9 seconds, across multiple systems on different domains. On a 2008 R2 or lower...

Multilevel Combo box in vb6

I am trying to create a multilevel combobox in vb6 similar to that seen in the attached image. This box will be used to select values and then save same to an access database (any insights into how I would design this aspect of the database is welcomed) an. I...

Compare items in an Array to items in a Variant in VB6

I have a Variant in VB6 with thousands of Strings. I also have an array of fixed length. I need to compare the contents of each and add the ones that match to a list. if array(i) = variant(1,i) then 'add to list End if I cannot figure out how...

C# Com Interop class methods are not visible in VB6?

I have created a C# Com Interop class in .NET and I have registered it appropriately on my dev machine as well as set Com-Visible to true in the assembly. However when I reference the library within my vb6 application I am able to see the library name, the class...

Need code for removing all unicode characters in vb6

I need code for removing all unicode characters in a vb6 string.

Why do I get an error 0x80029C4A (TYPE_E_CANTLOADLIBRARY) on anything other than my dev box?

I've read plenty of answers on here about how to deal with the error 0x80029C4A (TYPE_E_CANTLOADLIBRARY) that say that regsvr is the way to go and checking the registry to make sure that the dll I'm using is properly registered. I've done all of this on computers other than my...

SQL query to return maximum values from multiple columns

I have the following tables in a SQL Server 2008 R2 database: Customers ========= CustID CustName ====== ======== 0 NULL 1 A 2 B 3 C InterestingCustomers ==================== CustID ====== 0 1 3 Orders ====== CustID OrderID InvoiceTotal Discount ====== ======= ============ ======== 0 NULL 2000 NULL 0 100 NULL...

Set vb6 form to instance of a hardcoded form

I have a 2 Forms. Form1 opens Form2. Form2 after clicking a value, sends that value to a textbox located in Form1. It is hardcoded so that inside Form2 it explicitly states Form1.txtbox.Text = "Whatever i clicked" Form2 then closes and I am now sitting at Form1, however the txtbox.text...

VB6 Initialize event called AFTER Terminate event for user controls

I have created a simple form in VB6, and added a simple, blank user control. The only code are Debug.Print statements in all major events. For some reason, when the form is closed, the order of events in the User Control are: Terminate Initialize Read Properties Resize Why is this...

Running SQL Files with Variety of DDL commands and INSERT operations from a VB6 Code

I have a VB6 application, which restores a BAK file to the Database and runs through some scripts. As there are large volume of SQL Scripts to run, I decided to move all in to a SQL File and then to run it from the Application. The SQL File is...

How to determine a path is a file or directory in vb6?

I'm working on a project that I need to get a path from the user and do sort of things on that path but I need to know what that path is. I can't do this by checking the extension. Because maybe a file doesn't have extensions. Is there any...

Exclusive OR (XOR) in vb6 versus c#

I am converting a vb6 program to c# and I cannot figure out why the results of my exclusive or operation are giving me different values. The vb6 code: 'serialNum = 884167284, and dSize = 1953312760 here' serialNum = serialNum Xor dSize 'serialNum = 1088322956 after this operation' serialNum =...

VB6 code explanation

I need to convert some of the legacy code which is currently in VB6 into C#. I am not able to understand this piece of code. Especially the InStr function, could someone please help me out with this and suggest me it's C# equivalent. For i = 1 To Len(sString)...

VB 6 Advanced Find Method in View Code

Lets say i have 3 table A,B,C. In every table i have some insert query. I want to using Find "ctrl+f" to find every insert query with some format. Example: i want to find code that contain "insert [table_name] value" no matter what is the table name (A or B...

Format of a VBP File reference line

Can any one tell me the format of the reference=\ lines in a Visual Basic 6 (VB6) project vbp file? Particularly what look like version numbers but i dont think are in the middle? e.g. Reference=*\G{835341D8-AF69-4753-BD84-89B39E426EBC}#1.0#0#C:\CASimpleCom.dll#CASimpleCom I think the first part is the COM GUID, the last two parts are...

How to correctly use On Error Goto for different HRESULT values

I am trying to read a file. The call is from VB to CPP dll. Here is my sample code snippet VB CALL Private Sub ReadFile(...) On Error GoTo Problem Dim errorString As String Sample.ReadFile basepath, filename, register, errorString GoTo Completed Problem: WriteToLogFile basepath + filename + errorString //error string...

How to call .dll coded in vb6 from AutoHotkey Script?

I need to call .dll file from AutoHotkey but can not while I can access dll from vb6 as follows //spaceCalculator.dll Dim obj As New spaceCalculator.calculate msgbox obj.getData("shapes",2,100,100); I want to call it from AutoHotkey as follows but throws error -3/-4. .dll in root folder of Script. DllCall("spaceCalculator.dll\getUsageData","Str","Shapes","Float",2,"Float",100,"Float",100) ...

how to populate an array using anither?

I'm working on an excersice of filling one array using another one . To things uneasy , I 'm trying to fill starting from a certain point in the first array.I'm using Vb6

ActiveX dll not working on IIS 8.5

ActiveX dll not working on IIS 8.5 We have a classic ASP application that uses and ActiveX dll to generate an image on the fly. It was working find on Window 2003 with IIS6. But we're migrating it to Windows 2012 and IIS 8.5. The DLL is registered on the...

How To I Write Copymem Lib “Kernel32” Alias “Rtlmovememory” In Vb.Net

below is my vb6 code Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Public Property Let Key(New_Value As String) Dim i As Long Dim j As Long Dim K As Long Dim dataX As Long Dim datal As Long Dim...