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

variable not defined at Make time, but OK in IDE

$
0
0
My program runs just fine in the IDE, but when I try to make an exe, I get "Variable Not Defined" errors.
This is where the error first occurs, on fgmVidCap:

Code:

Public Function StartCamera(ByVal CameraName As String) As Boolean
    Dim AspectRatio As Double
    If Not fgmVidCap Is Nothing Then
        Error = 500
        Exit Function
    End If
    Set fgmVidCap = New QuartzTypeLib.FilgraphManager
    Error = BuildGraph(fgmVidCap, CameraName & FILTERLIST, CONNECTIONLIST) + 1
    If Error >= 1 Then
        Set fgmVidCap = Nothing
        Exit Function
    End If

I have a User Control, which includes:

Code:

     
Public fgmVidCap As QuartzTypeLib.FilgraphManager 
Public fiVidCap As QuartzTypeLib.IFilterInfo 
Public bv2VidCap As QuartzTypeLib.IBasicVideo2
Public vwVidCap As QuartzTypeLib.IVideoWindow

Both items start with Option Explicit.

I think this is possibly related to Early/Late Binding, but cannot figure out how to fix it!

Any help/suggestions will be welcome!

TIA.

Jim

need help with adding data to a table from a user form

$
0
0
hello i have toggle buttons from a-z each named: adda, addb, addc ect
i also have a text box named addtext

what i am hopeing to accomplish is to be able to toggle the button A (adda)
type into the text box named (addtext) foe example: Apple
when i click on the button called (addsave)

i want it to recognise that i have my A button toggled and save the text from the textbox and put it into a table named (tbla)
in a field named (Amplifier Name) on the left of my amplifier name field i have a field named numbers.

when i add to the amplifier name field i want the field to the left of this to auto populate the field on the left.

For example:
1 Apple1
2 Apple2
3 Apple3
Apple4

when i have added apple to the amplifier name field i want the field to the left of this called numbers to autopopulate a number.

any help would be greatly apreciated

[RESOLVED] Win7 Explorer Themed Selection pszClassList

$
0
0
Does MS provide pszClassList for Win7 File Explorer Theme Selection, so that I can fill OpenThemeData API to draw Hover and Selection Rectangle? Or just doesn't exist? If doesn't have, how to simulate? I want to draw such style for my ListBox.

Refer to my attached pic.

Edited: I open VBAccelerator's Theme explorer, it doesn't have "ListBox" theme.:( No wonder .NET ComboBox and ListBox also own plain focus rectangle.
Attached Images
 

[RESOLVED] variable not defined at Make time, but OK in IDE

$
0
0
My program runs just fine in the IDE, but when I try to make an exe, I get "Variable Not Defined" errors.
This is where the error first occurs, on fgmVidCap:

Code:

Public Function StartCamera(ByVal CameraName As String) As Boolean
    Dim AspectRatio As Double
    If Not fgmVidCap Is Nothing Then
        Error = 500
        Exit Function
    End If
    Set fgmVidCap = New QuartzTypeLib.FilgraphManager
    Error = BuildGraph(fgmVidCap, CameraName & FILTERLIST, CONNECTIONLIST) + 1
    If Error >= 1 Then
        Set fgmVidCap = Nothing
        Exit Function
    End If

I have a User Control, which includes:

Code:

     
Public fgmVidCap As QuartzTypeLib.FilgraphManager 
Public fiVidCap As QuartzTypeLib.IFilterInfo 
Public bv2VidCap As QuartzTypeLib.IBasicVideo2
Public vwVidCap As QuartzTypeLib.IVideoWindow

Both items start with Option Explicit.

I think this is possibly related to Early/Late Binding, but cannot figure out how to fix it!

Any help/suggestions will be welcome!

TIA.

Jim

Can I copy all properties from one control to another in s single statement?

$
0
0
Looking for something like:

command2 = command1

so that all relevant properties will be the same.

Is it possible?

Windows 10 Manifest file for VB6?

$
0
0
I've got a VB6 program that I distribute. I know nothing about Manifest files but I hear we will need one with Windows 10. My application doesn't require Admin and works well enough on Windows 7 and 8 without a Manifest file. Will I really need one?

The program comes with a pile of .DLL and .OCX files for things like scanners and word processing. Do I need to list every DLL and OCX inside the manifest? Anybody have a decent sample for a VB6 program?

Many thanks in advance for your help.

Finding text files on a directory.

$
0
0
I have a loading program which I wrote a few years ago, and I'd like to make some changes to it.

It's only function is to load text files from a network drive into our Oracle database. It works fine, but here's how it currently works.

Open the app-->click "Select file"-->select the text file from the dialogue box-->select "Run"--> file loads and is moved to another directory.

The text files in the directory are generated one per day. Sometimes when I go to load the data there are a few days worth of files in there, and sometimes it's just one file I need to load.

What I'd like to do is modify the program so that upon opening it just searches the directory for text files and loads them automatically.

Since the program is already written as stated above, I just need to know how to scan a directory for text files. I can make it work from there.

I've read about the DIR function as well as some other methods, but I'm not sure I get them. Any tips or nudges in the right direction would be appreciated.

Program for captcha generation and verification in login

$
0
0
Please give the program for captcha generation and verification in vb6????????

Making my codwe shorter and Easier to read and Write

$
0
0
Hey guys I have this piece of code for running a Stored Procedure, and I was wondering if there is a way of cutting code like:

Code:

  uPar = .CreateParameter("@PropertyID", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@PropertyID").Value = Val(lblPropertyIDValue.Text)

As I have a lot of stored procedures in my system this takes a lot of time, my boss seems to think there could be a way to possible cut this down to one line of code and make it a lot easier to read and write, though I'm not sure what way to go about this.

Hope someone can help.

Thanks

Code:

Public Function SaveProperty() As Boolean
    '** Save Current Personal Data Record

    ' Error Checking
    On Error GoTo Err_SaveProperty

    ' Dimension Local Variables
    Dim uRecSnap As ADODB.Recordset
    Dim uPar As ADODB.Parameter

    ' Check For Open Connection
    If uDBase Is Nothing Then
        OpenConnection()
        bConnection = True
    End If

    ' Run Stored Procedure - Save Property Record
    uCommand = New ADODB.Command
    With uCommand
        .ActiveConnection = uDBase
        .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
        .CommandTimeout = 0
        uPar = .CreateParameter("@PropertyID", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@PropertyID").Value = Val(lblPropertyIDValue.Text)
        uPar = .CreateParameter("@PropertyManager", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 60)
        .Parameters.Append(uPar)
        .Parameters("@PropertyManager").Value = cmbPropertyManager.Text
        uPar = .CreateParameter("@AddressLine1", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@AddressLine1").Value = txtAddress1.Text
        uPar = .CreateParameter("@AddressLine2", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@AddressLine2").Value = txtAddress2.Text
        uPar = .CreateParameter("@AddressLine3", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 20)
        .Parameters.Append(uPar)
        .Parameters("@AddressLine3").Value = txtAddress2.Text
        uPar = .CreateParameter("@Town", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@Town").Value = txtTown.Text
        uPar = .CreateParameter("@PostCode", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@PostCode").Value = txtPostCode.Text
        uPar = .CreateParameter("@Availabilty", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@Availabilty").Value = chkAvailable.Checked
        uPar = .CreateParameter("@Available", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@Available").Value = dtpAvailable.Text
        uPar = .CreateParameter("@Factored", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@Factored").Value = -chkFactored.Checked
        uPar = .CreateParameter("@FactorsName", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 20)
        .Parameters.Append(uPar)
        .Parameters("@FactorsName").Value = txtFactorName.Text
        uPar = .CreateParameter("@FactorsEmail", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@FactorsEmail").Value = txtFactorsEmail.Text
        uPar = .CreateParameter("@PropertyBuilt", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@PropertyBuilt").Value = dtpPropertyBuilt.Text
        uPar = .CreateParameter("@PropertyValue", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@PropertyValue").Value = txtPropertyValue.Text
        uPar = .CreateParameter("@MimimumFee", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@MimimumFee").Value = txtMinimumFee.Text
        uPar = .CreateParameter("@Commission", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@Commission").Value = -txtCommision.Text
        uPar = .CreateParameter("@CostSuthorisationAmount", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 20)
        .Parameters.Append(uPar)
        .Parameters("@CostSuthorisationAmount").Value = txtCostAuthorisationAmount.Text
        uPar = .CreateParameter("@Vacant", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@Vacant").Value = chkVacant.Checked
        uPar = .CreateParameter("@VacantDate", ADODB.DataTypeEnum.adLongVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
        .Parameters.Append(uPar)
        .Parameters("@VacantDate").Value = dtpVacant.Text
        uPar = .CreateParameter("@StartingRent", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput)
        .Parameters.Append(uPar)
        .Parameters("@StartingRent").Value = txtStartingRent.Text

        .CommandText = "PropertyMaster_SaveRecord"

        .Execute()
    End With

    ' Close Connection
    uRecSnap = Nothing
    uCommand = Nothing
    If bConnection Then CloseConnection()
    SaveProperty = True

 Err_SaveProperty:
    If Err.Number <> 0 Then
        sErrDescription = Err.Description
        WriteAuditLogRecord("clsProperty", "SaveProperty", "Error", sErrDescription)
        SaveProperty = False
    End If

End Function

Error no: 484 Problem getting printer information from the system. in VB 6 app

$
0
0
I have a VB 6 app which is a server product. If a user working on a workstation sends a request from their workstation to the server to print to a specific printer, my VB app throw up the error:
Error no: 484 Problem getting printer information from the system. Make sure the printer is set up correctly and the printed output does not occur.

However, if the app is run on a desktop or directly on the server, then NO error occurs despite calling the same printer.

Can anyone help me to trouble shoot this problem. Just bear in min that the workstation is connected to the server where my app is installed and only when the request comes from a User via their workstation. The printer has been assigned User permissions and the same use can print to the same printer if my app is installed on a desktop strange?


Thanks for any help
Regards
Mark
:ehh:

How to get pixel and import it to table

$
0
0
i've been looking for code that can get me value pixel from image, but i just got code that display the value of pixel and just one pixel from whole image. what i want is all of value pixel from image that has been imported to table form or to excel, like this Name:  example.jpg
Views: 89
Size:  25.9 KB
is there anyone that can help me, please?
anything
thx
Attached Images
 

How to make a simple matrix function to do two basic operation rows ?

$
0
0
Hi community!!
How to make a simple matrix function to do two basic operation rows ?
my basic operations used on the rows of a matrix are:
a)Adding two rows within a matrix together
b)Multiplying a row with a number
Sub OPERATIONROWS(): On Error Resume Next
Dim Rows As Range, n As Range, Offsetm As Integer, Offseta As Integer

Set Rows = Application.InputBox("Selecct row ranges (n, m y a) to perform operation row " & Chr(10) & _
"NOTE: hold Ctrl while you select cells and use right clic to select cells", Type:=8)

If Rows Is Nothing = True Then Exit Sub


If Rows.Areas.Count <> 3 Then
MsgBox "you must select 3 ranges"
Exit Sub
End If


If Not (Rows.Areas(1).Rows.Count = 1 And _
Rows.Areas(2).Rows.Count = 1 And _
Rows.Areas(3).Rows.Count = 1) Then
MsgBox "range can only have one row"
Exit Sub
End If


If Not (Rows.Areas(1).Cells.Count = Rows.Areas(2).Cells.Count And _
Rows.Areas(2).Cells.Count = Rows.Areas(3).Cells.Count) Then
MsgBox "range must have same numbe rof cells"
Exit Sub
End If


Offsetm = Rows.Areas(2).Row - Rows.Areas(1).Row
Offseta = Rows.Areas(3).Row - Rows.Areas(1).Row
For Each n In Rows.Areas(1)
ActiveCell = n + n.Offset(Offsetm) * n.Offset(Offseta)
Name:  visual_basic_funcion_sencilla.jpg
Views: 42
Size:  80.0 KB
Bye
Attached Images
 

Advanced Shell In Visual Basic

$
0
0
Hello everyone,

I am trying to access a second option on the "advanced sharing settings" in control panel.
Code:

This is my code: "Shell:::{8E908FC9-BECC-40f6-915B-F4CA0E70D03D}, vbNormalFocus"
which allow me to open "advanced sharing settings" but how could I make it go to the advance option?
I mean, back in Windows XP when I used to open or run all control panel applet I used to add 1,2,3, etc.
to go to a diferent parts or zone's on any particular option opened from visual basic.
With some other options on control panel what worked for me is adding "\settings" at the end of the GUID,
but in the case with this option thats not an alternative option to go to that part of the advancee settings.
Any idea, suggestion, help will be appreciate, thanks in advance.

visual basic

$
0
0
When you press a button I want to turn labels (with their current value) into textboxes.

Compiler Error : Argument Not Optional

$
0
0
Hello.
I am getting a compiler error : Argument Not Optional. Please help.

here is code :

Code:

Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset


Private Sub cmdAdd_Click()
rs.AddNew
Frame1.Visible = True
cmdAdd.Enabled = False
cmdUpdate.Visible = True
End Sub



Private Sub cmdSearch_Click()
n = Val(InputBox("Enter th Book Id to Search"))
rs.MoveFirst
Do While rs.EOF = False
If rs.Fields(0) = n Then
Frame1.Visible = True
Text1.Text = rs.Fields(0)
Text2.Text = rs.Fields(1)
Text3.Text = rs.Fields(2)
Text4.Text = rs.Fields(3)
Exit Do
End If
rs.MoveNext
Loop
End Sub

Private Sub cmdUpdate_Click()
rs.Fields(0) = Val(Text1.Text)
rs.Fields(1) = Text1.Text
rs.Fields(2) = Text1.Text
rs.Fields(3) = Val(Text4.Text)
rs.Update
End Sub

Private Sub Form_Load()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Amit\Documents\book.mdb;Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = conn
rs.Source = "Select * from book"
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open
rs.Move
End Sub


Download a web page into a text file

$
0
0
Hello !

In an application I declare:

Code:

Public Declare Function URLDownloadToFile Lib "urlmon" _
    Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
    ByVal szURL As String, ByVal szFileName As String, _
    ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

use the function:

Code:

Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function

and:

Code:

URLDownloadToFile 0, "https://some_url.com", "TextFile.txt", 0, 0
.....
.....

to download a, not so large, web page into a text file.

When I start the application the first time often nothing happens. (Nothing is downloaded !)

But if I first manually, with a web browser, open the same website, close it again and thereafter re-run the application, everything works as it should and then every attempt !

At least that's the case in design mode....

What can I add to the application to make it download the web page at the first start, without having to preopen the website ?

Best regards and thanks in advance.

/Kalle

VB6 + Mschart: HELP. Titles not easy to red / how to change resolution?

$
0
0
Hi there.
Please look at these pictures.
The data titles are very difficult to read.
Maybe I can change the resolution of mschart or something?

Name:  Dibujo1.jpg
Views: 47
Size:  19.2 KBName:  Dibujo2.jpg
Views: 44
Size:  25.4 KBName:  Dibujo3.jpg
Views: 42
Size:  17.9 KB
Attached Images
   

[RESOLVED] you tried to execute a query that does not include the specified expression why?

$
0
0
i am getting this error why?
Code:

you tried to execute a query that does not include the specified expression as part of an aggregate 'TempDate'
what is wrong with the code?
Code:

Dim DateToday As Date
DateToday = Format(Now, "DD/MM/YYYY")

Dim RsA As New ADODB.Recordset
RsA.Open "Select TempCash.TempDate ,Sum(TempCash.TempPay) AS SumOfTempPay FROM TempCash Where TempMethod = 'Cash' AND TempDate = #" & DateToday & "#", CN

tnx for any help
salsa31

[RESOLVED] Need help taking a screenshot

$
0
0
Some time ago I have found this code somewhere in the vastness of the internet:

Code:

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long


Private Sub Command1_Click()

Picture1.AutoRedraw = True
       
BitBlt Me.Picture1.hDC, 0, 0, Screen.Width \ Screen.TwipsPerPixelX, Screen.Height \ Screen.TwipsPerPixelY, GetDC(GetDesktopWindow), 0, 0, vbSrcCopy
       
ReleaseDC GetDesktopWindow, GetDC(GetDesktopWindow)

SavePicture Picture1.Image, App.Path & "\Screenshot.bmp"

End Sub

I like this method because the code is short and it is pretty easy to understand it but there is one problem with it. After screenshot is saved to the BMP file screenshot is cropped to the size of PictureBox so it is no more a full image of the screen. So first question will be how to get full image not cropped? And the second question will be is it possible to write image directly to the BMP file instead of first writing it to the PictureBox?

Thank you in advance for any help you can provide!

Finding a substring in a Word document

$
0
0
Using vb6, eventually I want to find where a month is first mentioned in a Word document and replace it with something else. It could be any valid month so I'll be comparing with a substring of eg "JanuaryFebruaryMarch...". The code below is self explanatory. I am using a short test string for now and as you can see from my remarks it works but not when I'm trying to match with a substring. I'd like some ideas that would fit into the structure I have.

Code:

'Project > References > Microsoft Word 14 Object Library
Option Explicit
Dim aPath As String
Dim aName As String
Dim FileName$
Dim wrdApp As Word.Application
Dim Finished As Boolean

Dim fMonth As String
Dim Looper As Integer


Private Sub Form_Load()
    aPath = "C:\Users\Alan\Documents\"
    Set wrdApp = CreateObject("word.application") ' that was needed in full test to allow close
End Sub

Private Sub Command1_Click()  ' edit now
    aName = aPath & "1InTest.docx"
    FileName$ = aName
    With wrdApp
        .Documents.Open FileName$
        .WindowState = wdWindowStateMaximize
        .Visible = True
        .Selection.Find.Text = "ARY"  '#### this works

        '.Selection.Find.Text = Mid("ARYOh", InStr(1, "ARYOh")) '####this does not
         
        .Selection.Find.Replacement.Text = "New Text"
        .Selection.Find.Execute Replace:=wdReplaceOne
       
    End With
       
       
   
           
    Finished = True 'if false, exits program without trying to close an unopened file

End Sub

Private Sub Command2_Click() 'CLOSE
    If Finished = True Then
        wrdApp.ActiveDocument.Close
        wrdApp.Quit
    End If
    Unload Me
End Sub

Viewing all 22112 articles
Browse latest View live


Latest Images

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