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

How to set pause before entering to stand by or hibernation mode?

$
0
0
I use WM_POWERBROADCAST to detect when the computer is start to going into sleep mode. But I need few seconds to complete the transaction in database before the computer goes to sleep. How to set pause before entering to sleep mode?

[RESOLVED] Delete Unchecked / Count checked Listview Records

$
0
0
Hi guys, i'm working on a project right now that requires deletion of unchecked items in Listview. I already have a working code but I guess this is not efficient if the number of items is 10,000+ or more. Here is my code:

Code:

recount:
        For i = 1 To lvRecords.ListItems.Count
            If Not lvRecords.ListItems(i).Checked Then
                lvRecords.ListItems.Remove i
                GoTo recount
            End If
        Next


I also have working code that counts/identify if the item is checked, however like my issue above this may take time if the records i'm processing is more than 10,000. Here is my code:

Code:

For i = 0 To lvRecords.ListItems.Count - 1
            If lvRecords.ListItems(i + 1).Checked Then
                countChecked = countChecked + 1
            End If
        Next


Is there any other efficient code than what i posted above that will provide the same functionality and results? Thanks in advance.

Unexpected error when using components

$
0
0
Hi everyone, recently my VB6 start having this strange problem. Every time I open up the components(ctrl+T), the program will give unexpected error message and the components list is left empty.

Name:  1.jpg
Views: 59
Size:  29.2 KBName:  2.png
Views: 49
Size:  30.5 KB

I can repopulate or use certain ocx manually but every time I re-open the components(ctrl+T), it'll give the same error and the list return back to empty.
I suspect there is a problem with registry but don't know how to trace which registry causing the problem.
I have tried to re-register several ocx/dll, repair vb6, running ccleaner(to clear orphan registry), scan for virus/malware, etc.
To bad I disabled system restore on the computer. Previously I can fix the issue with system restore.
I don't know what is causing this problem but I would guess that it's either some components from old programs that I removed(videograbber) or some new components I installed(Digital Persona Fingerprint).

Have anyone encounter the same problem? Or probably have a suggestion on the matter?
I also need help with clean re-installation procedure. The one which will remove all registry related to VB6.

Thank you.
Attached Images
  

How can my activex DLL get the HWND of the app that declared it? (without passing)

$
0
0
How can my dll obtain the hwnd of the app that called it? I've made an activex dll using Ron Petrusha's technique (so that I can declare it instead of "reference" it).. so of course I can pass the hwnd from the program that calls the dll.. but I don't want there to be communication that like. I would like the dll to independently get the hwnd of the parent program that has loaded it. Is this possible? Thanks.

Expiry Date Item Count

$
0
0
Hello


i am New User here, i work in vb6

can i have vb6 code for Expiry date
Name:  149743876331831.jpg
Views: 52
Size:  38.9 KB


I Use This Code for Expire Date:


Private Sub cmd1_Click()
On Error Resume Next
Call connect_Data
Dim date1 As Date
With rs_find
If .State = adStateOpen Then .Close
.Open "select * from Table Where Date_End = " & DateDiff("d", Date, rs!Date_End) - Text1.Text, con, adOpenDynamic, adLockPessimistic
Dim dy As Integer
If Not rs.EOF Then
Label1.Caption = .RecordCount
rs.MoveNext
End If
End With
End Sub


But is Not Working
Attached Images
 

[RESOLVED] Problem "Making" Large Project Group on Windows 10

$
0
0
I finally decided to bite the bullet and move my main development environment from a WinXP VM to my main Windows 10 Pro machine. Installation of the VB6 IDE went smoothly, migration and registration of my DLLs, OCXs, Add-ons, etc... went smoothly too. After getting everything migrated, I ran my main project group (quick count puts it at just under 40 individual projects) and it compiled and ran as expected.

So far so good I thought - until I tried to make the project group (File > Make Project Group).

The first 3 projects were built and binaries were produced, again just as expected. The 4th project, which was the first one to reference one of the previous projects failed to compile with an error that a User-defined type was not defined (the type being a class from one of the previously compiled projects). Sure enough, if I look in the Project References, the reference to the project that hosts that class has been removed, and I can't add it back in while the project group is open after I've tried to make the project group (I select it, but when I return to the references window the checkbox is cleared).

If I open my projects separately/one-by-one, I can compile them all without issue, but this will become a bit of a pain to have to do on a regular basis.

All of the projects have Binary Compatibility set for the DLLs and OCXs.

Anyone have any idea what could cause a project group to fail like this? To recap:

  • Binary compatibility is set for all DLL and OCX projects
  • Project Group compiles and runs perfectly in the IDE
  • Individual project binaries are built fine when being made separately
  • Attempting to make the project group fails at the first project that references a previously built project


Appreciate any thoughts/things to try/pointers toward a solution, thanks :)

Graph from Array

$
0
0
hi guys,
newbie here... i need a solutions... cant make it happen as actually dont know how to make it happen...

I'm making a monitoring software for a chiller. It reads temperature and does several things like alert, and etc.
apart from that works, it also supposed to show a line graph. The item is based on arduino. Via Ethernet i receive strings every after 10 seconds (though receive interval is a configurable) and i store the received temperature as "rcvdTemp = rcvdTCPStr(0)"

Now, i want to show a graph of last five minutes... (it will be a trend curve). Thus the initial value can be at left most or right most, no issues. (I think left most is better as graphTemp(0) at time 0 and till time 30, where time is here the sample number, not the actual times)

Once the say time30 is plotted, then time 0 will be replaced by time 1 and time 30 will be the latest 31st sample. Thus eventually it will be a trend curve from left to right and after filling the slots, it will be the "latest reading at right most place". Hope I can made it understand...

So all I need is a graph, autorefreshed, but "not via form reload" as i have a TCP socket stream receiving (connected to server). and the values will be received ones, which will be after filling the array at index 30th, the 31st will be the 30th (limited to 30 samples say). 32 later will also be 30th, whereas 30 will become 29. Ideas guys???

Mishu~

When memory for static variable is allocated?

$
0
0
Will memory allocated when you first time access to method where static variable is stored or immediately after you run application?

Some vb6 questions

$
0
0
hello everyone!
im new to this forum, im a game developer and now im developing a 2d game with vb6.
ive got some questions:
1)Is there any tutorial on how to make a vb6 updater?
2)How could i make the game protection? So it wont let and injections etc etc?
3)Finally, can i add lua? If so, is there any tutorial?

Date Picker (DTPicker) back color

$
0
0
Has anyone worked out how to change the BackColor of the DTPicker? I'm talking about the back color when it's closed up, and not on the little month-popup.

[RESOLVED] When memory for static variable is allocated?

$
0
0
Will memory allocated when you first time access to method where static variable is stored or immediately after you run application?

[RESOLVED] Date Picker (DTPicker) back color

$
0
0
Has anyone worked out how to change the BackColor of the DTPicker? I'm talking about the back color when it's closed up, and not on the little month-popup.

Two Part Naming Tables (Schema.TableName)

$
0
0
Hello,

Good evening.

I am using SQL Server 2012 as database.
Created all tables using two part naming model. VB consider two part naming query as syntax error.
Could any body please let me know any solutions.

Thank you.

Check if window is minimizing/restoring or fully minimized/restored

$
0
0
I'm using this code to capture screen every time the top window is minimized/restored or focus changed to other window.

Just create a picturebox, a timer, and paste this code:

Code:

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


Private Declare Function BitBlt Lib "gdi32.dll" (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 GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long


Private Const SRCCOPY      As Long = &HCC0020
Dim lastforegroundWindow As Long
Dim DeskDC As Long


Private Sub Form_Load()
Picture1.Top = 0
Picture1.Left = 0
DeskDC = GetDC(GetDesktopWindow)
End Sub

Private Sub Form_Resize()
Picture1.Width = Me.Width
Picture1.Height = Me.Height
End Sub

Private Sub Timer1_Timer()
Dim foregroundWindow As Long, r As RECT
foregroundWindow = GetForegroundWindow()
Call GetWindowRect(foregroundWindow, r)
If foregroundWindow <> lastforegroundWindow Then
BitBlt Picture1.hDC, 0, 0, 1000, 1000, DeskDC, 0, 0, SRCCOPY
lastforegroundWindow = foregroundWindow
End If
End Sub

This code works fine if I switch to other windows without minimize/restore. But if i minimize a window (for example - notepad), my application capture the screen at the time notepad is minimizing/restoring which i don't want. I just want my application check/wait for notepad fully minimized/restored and capture the screen after that.

Name:  notepad-minimizing.jpg
Views: 38
Size:  43.0 KB

The only way i found to workaround is using Sleep api to wait for 1 second, but it's not a good idea . Is there any other method that i don't know?

Thank you all!
Attached Images
 

[RESOLVED] Unexpected error when using components

$
0
0
Hi everyone, recently my VB6 start having this strange problem. Every time I open up the components(ctrl+T), the program will give unexpected error message and the components list is left empty.

Name:  1.jpg
Views: 114
Size:  29.2 KBName:  2.png
Views: 102
Size:  30.5 KB

I can repopulate or use certain ocx manually but every time I re-open the components(ctrl+T), it'll give the same error and the list return back to empty.
I suspect there is a problem with registry but don't know how to trace which registry causing the problem.
I have tried to re-register several ocx/dll, repair vb6, running ccleaner(to clear orphan registry), scan for virus/malware, etc.
To bad I disabled system restore on the computer. Previously I can fix the issue with system restore.
I don't know what is causing this problem but I would guess that it's either some components from old programs that I removed(videograbber) or some new components I installed(Digital Persona Fingerprint).

Have anyone encounter the same problem? Or probably have a suggestion on the matter?
I also need help with clean re-installation procedure. The one which will remove all registry related to VB6.

Thank you.
Attached Images
  

Excel won't close

$
0
0
I have a VB6 application that opens excel file, do some stuff and close it
every thing is going fine , but excel remains active in the task manager
here is my code:
Code:

'======================================
Dim XcLApp As excel.Application
Dim XcLWB As excel.Workbook
Set XcLApp = New excel.Application
Dim XcLWS As excel.Worksheet
Set XcLWB = XcLApp.Workbooks.Open(App.Path & "\reports\rawateb_rep_tsleem.xls")
Dim i As Integer
Dim x As Integer
Dim shcount As Integer
SRC_SQL = "SELECT distinct loc from salary_list"
Set RS = New ADODB.Recordset
If RS.State = adStateOpen Then RS.Close
RS.Open SRC_SQL, CN, adOpenDynamic, adLockOptimistic
If RS.RecordCount <> 0 Then
RS.MoveFirst
shcount = 0
Do While Not RS.EOF
    shcount = shcount + 1
    XcLWB.Sheets("All").Copy after:=Sheets(1)
    ActiveSheet.Name = RS.Fields(0)
    RS.MoveNext
Loop
Set RS = Nothing

For J = 2 To XcLWB.Worksheets.count
    Set XcLWS = XcLWB.Worksheets(J)
    x = 1
    With MSFlexGrid1
        For i = 1 To .Rows - 1
            If .TextMatrix(i, 3) = XcLWB.Sheets(J).Name Then
                XcLWS.Range(Addres_Excel(x + 4, 1)).Value = .TextMatrix(i, 1)
                XcLWS.Range(Addres_Excel(x + 4, 2)).Value = .TextMatrix(i, 3)
                XcLWS.Range(Addres_Excel(x + 4, 3)).Value = .TextMatrix(i, 7)
                XcLWS.Range(Addres_Excel(x + 4, 4)).Value = .TextMatrix(i, 8)
                XcLWS.Range(Addres_Excel(x + 4, 5)).Value = .TextMatrix(i, 9)
                XcLWS.Range(Addres_Excel(x + 4, 6)).Value = .TextMatrix(i, 10)
                XcLWS.Range(Addres_Excel(x + 4, 7)).Value = .TextMatrix(i, 13)
                XcLWS.Range(Addres_Excel(x + 4, 8)).Value = .TextMatrix(i, 16)
                XcLWS.Range(Addres_Excel(x + 4, 9)).Value = .TextMatrix(i, 18)
                XcLWS.Range(Addres_Excel(x + 4, 10)).Value = .TextMatrix(i, 20)
                XcLWS.Range(Addres_Excel(x + 4, 11)).Value = .TextMatrix(i, 22)
                x = x + 1
            End If
        Next i
    End With
    XcLWS.Range(Addres_Excel(x + 4, 3)).Formula = "=sum(c2:c" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 4)).Formula = "=sum(d2:d" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 5)).Formula = "=sum(e2:e" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 6)).Formula = "=sum(f2:f" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 7)).Formula = "=sum(g2:g" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 8)).Formula = "=sum(h2:h" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 9)).Formula = "=sum(i2:i" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 10)).Formula = "=sum(j2:j" & x + 3 & ")"
    XcLWS.Range(Addres_Excel(x + 4, 2)).Value = "ÇáãÌÇãíÚ"
    XcLWS.Range("c5:l" & x + 4).HorizontalAlignment = xlCenter
    XcLWS.Range("c5:l" & x + 4).VerticalAlignment = xlCenter
    XcLWS.Range("a5:l" & x + 4).Font.Name = "Simplified Arabic"
    XcLWS.Range("a5:l" & x + 4).Font.Size = 20
    XcLWS.Range("a5:l" & x + 4).Borders.LineStyle = xlContinuous
    XcLWS.Range("a5:l" & x + 4).Borders.Weight = xlThin
    XcLWS.Rows("5:" & x + 4).RowHeight = 55

Next J
    XcLApp.Visible = True
    XcLApp.DisplayAlerts = False
    XcLWS.PageSetup.PrintTitleRows = XcLWS.Rows(1).Address
    XcLWS.PageSetup.CenterHeader = XcLWB.Name
    XcLWS.PageSetup.RightFooter = "Page &P"
    XcLWS.PageSetup.Orientation = xlLandscape
    XcLWS.PageSetup.FirstPageNumber = xlAutomatic
    XcLWB.SaveAs ("e:\rawateb\" & Month(Now) & "-" & Year(Now) & " ÊÓáíã - ßÔÝ ÑæÇÊÈ ÔÑßÉ ÇáÔåÇãÉ áÎÏãÇÊ ÇáÊäÙíÝ ")
End If
    For i = 1 To XcLApp.Workbooks.count
        XcLApp.Workbooks(i).Close savechanges:=True
    Next i
    XcLApp.DisplayAlerts = True
    XcLApp.Quit
    Set XcLWB = Nothing
    Set XcLApp = Nothing
    Shell "explorer.exe /e, " & "e:\rawateb", vbNormalFocus

Vb6 and Outlook Express

$
0
0
Outlook Files:

Code:

Name                        VB6 Reference        Office Dll File
----------------------        --------------        ---------------------------------
Microsoft Outlook 97        Msoutl97.olb        Microsoft Office 97        Mso97.dll
Microsoft Outlook 2000        Msoutl9.olb        Microsoft Office 2000        Mso9.dll
Microsoft Outlook 2002        MSOutl.olb        Microsoft Office 2002        MSO.dll
Microsoft Outlook 2003        MSOutl.olb        Microsoft Office 2003        MSO.dll
Microsoft Outlook 2007        MSOutl.olb        Microsoft Office 2007        MSO.dll

Product Name?    File Locations
-------------        ------------------------------------------
Office 97        C:\Program Files\Microsoft Office\Office
Office 2000        C:\Program Files\Microsoft Office\Office
Office XP        C:\Program Files\Microsoft Office\Office10
Office 2003        C:\Program Files\Microsoft Office\Office11
Office 2007        C:\Program Files\Microsoft Office\Office12

I have Office 97 and 2000 and use the later version as it exposes more functions to VB. I would like
to get the latest Office / Outlook files available, but I’m not all that sure what’s bundled with what.

If I load Office 2007 on my machine, will that also install the latest files needed by VB6?

[RESOLVED] Find No of first line showing in textbox

$
0
0
Hi All,

In a multi - line text box which has scrolled. (i.e. the first line is not shown) Is there a way to find the number of the first line that does show?

Filter Date on DataEnvironment vb 6 stuck

$
0
0
hello guys ..
i have some trouble when i want use 2 dtpicker to filter my report by date from dataenvironment..
this my code
Code:

DataEnvironment2.rsCommand1.Open
DataEnvironment2.rsCommand1.Filter = "tanggal = 5/27/2017" --> this code work but i don't use like this.
DataEnvironment1.rsCommand1.Filter = "tanggal >=  #" & DTPicker1.Value & "# and tanggal <= #" & DTPicker2.Value & "#" ---> this code not filter
DataReport2.Show
DataEnvironment2.rsCommand1.Close

please help me guys.
thanks

how to filter data by date on crystal report vb 6 using dtpicker

$
0
0
I stuck filtering date in crystal report via vb 6 using dtpicker...
first i using this code running without error but not filter .. this is my code :

Code:

DataEnvironment2.rsCommand1.Open
DataEnvironment2.rsCommand1.Filter = "tanggal >=  #" & DTPicker3.Value & "# and tanggal <= #" & DTPicker4.Value & "#"
CR2.Refresh
CR2.Show
DataEnvironment2.rsCommand1.Close
Unload Me

this code work and filtering on dataReport but in crystalreport not filtering.
please help me guys
thank you..
Viewing all 21678 articles
Browse latest View live


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