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

How to load PNG image?

$
0
0
I want to load PNG(Portable Network Graphics) image on the PictureBox or Image control but failed.
Is there any control that VB6 provides?
If not, is there some workaround that I can load PNG image?

Creating PictureBox at run-time

$
0
0
I want to create PictureBox at run-time.
I'm wondering if anybody could suggest the way how to do it.

Check if record exist then do UPDATE, if not, then do INSERT. vb 2010 ms access

$
0
0
Hi,

I would like to ask help. I am currently creating a time keeping system. My only problem right now is with regards to time-in and time-out of the employee.

If button timeinout is clicked, it should check if there is a data that has time in, if there is, it should do time out.
the fields under TKS table, (TechMID, FullName, DateIN, TimeIN, DateOUT, TimeOUT, TotalHours).



Private Sub btntimeinout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntimeinout.Click
Dim cmd As New OleDb.OleDbCommand


Dim TechMID As String
Dim FullName As String
Dim DateIN As String
Dim TimeIN As String
Dim DateOUT As String
Dim TimeOUT As String

TechMID = lbltmid.Text
FullName = lblfn.Text
DateIN = lbldate.Text
TimeIN = lbltime.Text
DateOUT = lbldate.Text
TimeOUT = lbltime.Text

try

Dim sql1 As String
Dim A As Integer

sql1 = "SELECT * FROM TKS WHERE TechMID = '" & TechMID & "' AND DateIN IS NULL"

Dim DA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql1, cnn)
Dim DS As New DataSet
DA.Fill(DS, "TKS")
A = DS.Tables("TKS").Rows.Count

If A > 0 Then
cmd.CommandText = "INSERT INTO TKS([TechMID], [FullName], [DateIn], [TimeIn]) VALUES ('" & TechMID & "','" & FullName & "','" & DateIN & "','" & TimeIN & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("Time In Successfully Added.")

Else


cmd.CommandText = "UPDATE TKS set [DateOUT] = '" & DateOUT & "', [TimeOut] = '" & TimeOUT & "' WHERE [TechMID] = '" & TechMID & "' AND [DateIN] IS NOT NULL"
cmd.ExecuteNonQuery()
MessageBox.Show("Time Out Successfully Added.")


End If

Catch ex As Exception

End Try

'close connection
cnn.Close()
End Sub

I am not sure how to do it. Please help me. I attached the project. Hoping for any help asap.

format number

$
0
0
i have MyVal=325687(as long dimensioned)

I need to format to have:

3.256,87

wath is the correct format parameter?

ImageList Image Question

$
0
0
I see that the max size for an ImageList is 256 x 256. Is there any alternative(s) I can use if I need the larger picture for the ListView Drag Image. This would occur when the user selects many items from the ListView to drag as a single drag operation and the image must hold icon and text of each item

Webbrowser - Run-time error '70' permission denied - how to prevent?

$
0
0
Problem with occasional permission denied '70' error, when user clicks table cell, in locally generated and loaded html document.

VB6 form, where webbrowser component;
- loads locally generated html file from local disk (WebBrowser1.Navigate2 absolutepathandfilename.html) and other usual stuff in document complete event, to make sure document is loaded.
- html document is plain html file without any javascript, frames or embedded objects.
- document is well formed and W3C validator (https://validator.w3.org/) validates it succesfully.

Code:

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.object) Then 'HTML document is ready
    Set objHTMLDoc = WebBrowser1.Document
    If (objHTMLDoc Is Nothing) = False Then
        bDocComplete = True
        'lhwnd = WebBrowser1.hwnd 'throws 80004005 error (access denied)
        WebBrowser1.SetFocus 'Does not work
    Else
        MsgBox "Unable to initialize html document " & vbCrLf & sHtmlDocFile , vbExclamation + vbOKOnly
    End If
Else
    MsgBox "Unable to instantiate webbrowser object.", vbExclamation + vbOKOnly
End If

Code:

Private Function objHTMLDoc_onclick() As Boolean
If objHTMLDoc.activeElement.className = "ts7" Then
    objHTMLDoc.activeElement.Style.backgroundColor = "SpringGreen" 'Feedback for user -> active selected table cell.
    sSelectedHTMLCode = CStr(objHTMLDoc.activeElement.outerText) 'OuterText contains clicked table cell text data.
    If (objClicked Is Nothing) = False Then
        'On Error Resume Next 'Workaround for the first round, when objClicked is nothing
        If (TypeOf objClicked Is IHTMLTableCell) Then 'IHTMLTableCell
            If sPreviousSelectedCode <> sSelectedHTMLCode Then
                objClicked.Style.background = "White" 'Restore previous selection 'Occasional permission denied error '70'
            End If
        End If
    End If
    Set objClicked = objHTMLDoc.activeElement
    sPreviousHTMLCode = sSelectedHTMLCode
End Sub

Error happens if/when user clicks 'directly' to ts7 cell, without first clicking somewhere else in webbrowser component area - but this is not consistent ie. does not happen avery time. Somehow it is linked to what is in table cell content fex. 1.0330 throws error every time, but 1.0338 never.

Workaround is to add On Error statement.
Code:

If sHTMLPreviousMatKoodi <> sHTMLMatkoodi Then
                On Error Resume Next 'Premission denied error '70' prevention
                objClicked.Style.background  "White" 'Restore previous selection

Any idea why error happens?

VB6 Wrapper Class for WinHTTP WebSockets?

$
0
0
See WebSocket for an overview.


I've been using some clunky 3rd party libraries for ws/wss WebSocket protocol clients. These are pretty painful and full of bugs. But I saw that a while back in Windows 8 or 8.1 Microsoft finally added support into WinHTTP. With Windows 7 and everything older sliding into oblivion it may finally be time to revisit this.

Sadly Microsoft stubbornly chose not to bother adding this to the WinHttpRequest object (or even providing it as a new WinHTTP DLL for Win7 and earlier), so we need to climb below this and deal with the raw API calls. That's a nuisance for many reasons, but no more so than trying to implement async operation, without which WebSockets aren't very useful anyway.

There's a C++ sample available: WinHTTP WebSocket sample

I was wondering if anyone had tried to either work from this to create a C++ ActiveX DLL (using ATL?) we could use, or perhaps had cobbled together a VB6 class based on the C++ sample? I'd like to avoid reinventing the wheel if somebody has one or the other working, preferably with at least basic documentation of its methods, properties, and events.

I don't need the server side, which is normally implemented as a web server extension anyway.

Crystal to PDF problem

$
0
0
VB6 application sends PDF files created by exporting Crystal Reports to PDF as an attachment to customers.
From time to time (not always) the process of exporting produces an error -2147189152 'Cannot find QE property'
I searched google and found out that the reason for it is MS Windows update KB3102429. Microsoft knows about this issue but I couldn't find any solution except uninstalling that update.
Does anybody know any other solution? Technicians responsible for user workstation support in companies which use our application often do not want to make the changes programmers are requesting.

Thank you

How to Prefix " % " Sign in Text Box?

$
0
0
hi, all

i want to Prefix a " % " sign in a right corner of my TextBox (as it is possible in Excel). at run time i will allow user to input any number like 5,10, etc, to textbox and i will use this text box number in calculation also. i want that sign as it is in textbox.

is it possible ? i have no idea for same.

plz. help, if anybody know about this.

thanking you,

Kaushal

quiz help!!

$
0
0
Ok, I have created a quiz in vb it has a username and a password. The user enters a username and password and it is saved in database and it is used to log on. Then they answer a quiz and get a score. I want it so that the score is added to database editing the column of the user logged in. Any suggestions.

Client Area

$
0
0
I have never been sure using system metrics how to align objects on a form correctly. I always seem to find myself adding a fudge here and there to get things just perfect.



To align things horizontally I use the following:


Code:

(SM_CXEDGE + SM_CXFRAME) object (SM_CXFRAME + SM_CXEDGE)

To align things vertically I use the following:


Code:

            SM_CYEDGE
                +
            SM_CYFRAME
                +
          SM_CYCAPTION
       
              object

            SM_CYFRAME
                +
            SM_CYEDGE


Is this the correct way to center objects on a form?

Thanks.

[RESOLVED] How to Prefix " % " Sign in Text Box?

$
0
0
hi, all

i want to Prefix a " % " sign in a right corner of my TextBox (as it is possible in Excel). at run time i will allow user to input any number like 5,10, etc, to textbox and i will use this text box number in calculation also. i want that sign as it is in textbox.

is it possible ? i have no idea for same.

plz. help, if anybody know about this.

thanking you,

Kaushal

UserControls and Line method

$
0
0
In VB you can draw a line using a controls built in method.

Picture1.line (0,0) - (100,100)

It's a strange arrangement of parameters which does not conform to the normal calling standard.

If writing a user control, the line method is available internally, but can you expose the line method to the calling program using the same format of passing arguments?

Say the user control is called Draw_Shapes, could the following be supported somehow?

Draw_Shapes.Line (0,0) - (100,100)


Thanks

Problem adding images to ImageList using function GetAssocIcon

$
0
0
I can add 30,000+ icons to the ImageList using this:

Code:

For n = 1 To 32000
  ImageList1.ListImages.Add , , Me.Icon
Next n

So, I know it's not a quantity issue but when I use GetAssocIcon function I can only add about 2,053 icons

I use DirListbox and FileListBox to point to c:\windows\system32

Here is the code

Form Code
Code:

  '
  '
For n = 0 To File1.ListCount - 1
  Path = Dir1.Path & "\" & File1.List(n)
  ImageList1.ListImages.Add , , GetAssocIcon(Path, False)
Next n
  '
  '

.BAS Module Code

Code:

Option Explicit

Private Const S_OK As Long = 0
Private Const MAX_PATH As Long = 260
Private Const SHGFI_ICON As Long = &H100&
Private Const SHGFI_LARGEICON As Long = &H0&  '32x32 pixels.
Private Const SHGFI_SMALLICON As Long = &H1&  '16x16 pixels.
Private Const SHGFI_USEFILEATTRIBUTES As Long = &H10&

Private Type SHFILEINFO
    hIcon As Long
    iIcon As Long
    dwAttributes As Long
    szDisplayName As String * MAX_PATH
    szTypeName As String * 80
End Type

Private Type PictDesc_Icon
    cbSizeofStruct As Long
    picType As Long
    hIcon As Long
End Type

Private Type Guid
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
End Type

Private Declare Function SHGetFileInfo Lib "shell32" Alias "SHGetFileInfoW" ( _
    ByVal pszPath As Long, _
    ByVal dwFileAttributes As Long, _
    ByVal psfi As Long, _
    ByVal cbSizeFileInfo As Long, _
    ByVal uFlags As Long) As Long

Private Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameW" ( _
    ByVal lpFileName As Long, _
    ByVal nBufferLength As Long, _
    ByVal lpBuffer As Long, _
    ByVal lpFilePart As Long) As Long

Private Declare Function OleCreatePictureIndirect Lib "olepro32" ( _
    ByVal lpPictDesc As Long, _
    ByVal riid As Long, _
    ByVal fOwn As Long, _
    ByRef lplpvObj As IPicture) As Long

Private IPictureIID As Guid

Public Function GetAssocIcon( _
    ByVal PathToFile As String, _
    Optional ByVal LargeIcon As Boolean = False, _
    Optional ByVal Extension As Boolean = False) As StdPicture
    Dim SFI As SHFILEINFO
    Dim Desc As PictDesc_Icon
   
    If Len(PathToFile) = 0 And Extension Then PathToFile = "x" 'Win7 "generic icon" request fix.
   
    If SHGetFileInfo(StrPtr(PathToFile), _
                    0, _
                    VarPtr(SFI), _
                    LenB(SFI), _
                    SHGFI_ICON _
                  Or IIf(LargeIcon, SHGFI_LARGEICON, SHGFI_SMALLICON) _
                  Or IIf(Extension, SHGFI_USEFILEATTRIBUTES, 0)) = 0 Then
        Exit Function
    End If
   
    If IPictureIID.Data1 = 0 Then
        'Initialize once on first call.
        With IPictureIID
            .Data1 = &H7BF80980
            .Data2 = &HBF32
            .Data3 = &H101A
            .Data4(0) = &H8B
            .Data4(1) = &HBB
            .Data4(2) = &H0
            .Data4(3) = &HAA
            .Data4(4) = &H0
            .Data4(5) = &H30
            .Data4(6) = &HC
            .Data4(7) = &HAB
        End With
    End If
   
    With Desc
      .cbSizeofStruct = Len(Desc)
      .picType = vbPicTypeIcon
      .hIcon = SFI.hIcon
    End With
   
    If OleCreatePictureIndirect(VarPtr(Desc), _
                                VarPtr(IPictureIID), _
                                True, _
                                GetAssocIcon) <> S_OK Then
        Set GetAssocIcon = Nothing
    End If
End Function

When the loop count reaches 2053 I get a Run-time error 7: Out of memory.

Is there something I need to do that is not in the above code?

Flexgrid combolist from database

$
0
0
Name:  untitled1.jpg
Views: 20
Size:  15.4 KB

I'm using a flexgrid to get data from the user.
As you can see I have 6 fields.
What I want on the field name ="UOM" the data will be coming from a database and it will work as normal combo box like this.
Name:  hi.JPG
Views: 19
Size:  4.4 KB

I'm newbie to VB6 and I really dont know the right sytax for this. :(

Help!:(
Attached Images
  

Help requied with datarport

$
0
0
I am facing a problem that I have to show database results from 3 different tables on a single report these three tables have are used for different purposes and want to show their headings details separately. I am using VB6 and designing this report in DataReport a common feature for this.
Table1 is for Menu Details
Having following fields: Bill_ID, Menu Type, Cost
Table2 is for Services Details:
Having following fields: Bill_ID, Service Name, Cost
Table3 is for Extra Details:
Having following fields: Bill_ID, Description, Cost
Now structure I want to is like this using common Bill ID, and want to show the headings for each table and then details of each table one by one like this

Code:

Bill ID: 1234567890

Menu Details
+-----------+--------+
| Menu Type | Amount |
+-----------+--------+
| Prod1    |    100 |
| Prod2    |    60 |
| Prod3    |    75 |
+-----------+--------+

Service Details
+--------------+------+
| Service Name | Cost |
+--------------+------+
| Service1    |  15 |
| Service2    |  17 |
+--------------+------+

Extra Details
+-------------+------+
| Description | Cost |
+-------------+------+
| Extra1      |  11 |
| Extra2      |  12 |
+-------------+------+
Total Amount: $xxxx

Help finding Agreed Secret

$
0
0
In my ongoing attempt to implement ECC (Elliptical Curve Cryptography) in TLS 1.2, I have run into a roadblock that I can't seem to get around.

Background:
To use ECDHE (Elliptical Curve Diffie-Hellman Ephemoral), one uses an internally generated Private Key and a Public Key from the other end to create a 32 byte Agreed (or Shared) Secret. This Secret is then combined with the 32 Byte Client Random and 32 byte Server Random to produce a 48 byte Master Secret from which the various Symmetric keys for the exchange are created.

Problem:
CNG (Cryptography Next Generation) is capable of producing the Agreed Secret, but it appears that the only way of recovering it is as a hashed value using:
Code:

BCryptDeriveKey(hAgreedSecret, StrPtr(BCRYPT_KDF_HASH), VarPtr(ParameterList), VarPtr(bAgreedSecret(0)), cbAgreedSecret, cbAgreedSecret, 0)
The second parameter can also be BCRYPT_KDF_HMAC or BCRYPT_KDF_TLS_PRF. BCRYPT_KDF_HMAC is an HMAC Hash, and I have tried using BCRYPT_KDF_TLS_PRF. In theory, it produces a 48 byte variable that should be the Master Secret, but unfortunately it is different value every time I run it with the identical input parameters. To be of any use to TLS, both ends must be able to generate the same Master Secret.

I started all this trying to figure out why I could not connect to a foreign server. RFC5903 provided sample data to verify the key generation. I hashed the Agreed Secret that RFC5903 said I should get, and that hash compared to the results of the call above. So I know that it is calculating the Agreed Secret correctly, but a hash of it however is useless to me. I found where the raw Agreed Secret is stored in memory, but it looks like it has been encrypted. I also located the Private Key and the Public Key in memory, but they also look like they are encrypted in the same manner.

Does anyone know what the operating system uses to encrypt this information?

J.A. Coutts

[RESOLVED] Type Mismatch

$
0
0
I'm noob with VB6 so bare with me. :(

I got an error with this code:

Dim i As Integer
With poFlexGrid
For i = 1 To .Rows - 1
.Cell(flexcpText, i, 5) = poFlexGrid.TextMatrix(i, 2) * poFlexGrid.TextMatrix(i, 3)
Next
End With

Error: Type Mismatch

what i'm trying to do is to multiply the unitcost to quantity and the result will reflect total amount.

Name:  untitled1.jpg
Views: 31
Size:  15.4 KB

I really don't know how to make this work.
I need help.

Thank you.
Attached Images
 

How can I run my program in background of a game?

$
0
0
G'day all, I have made a game companion similar to a trainer but not quite. It is loaded with information I have researched about the game via the net and a huge book I bought about it.
I have tried many "Always On Top" scripts but none can compete with the game even when the game is set to windowed mode (it still hogs the whole screen including the Task-bar) and I have even tried using a timer to keep applying the "Always On Top" function.
I have tried activating it with Key Press, Key Down and Key Up functions but it doesn't have focus to begin with. As soon as the game starts my program might as well not exist. :(

Program: VB 6
Game: Fallout 4.

As always, any advice to resolve this issue would be greatly appreciated.

3 levels of 'split' string; 1 level not working

$
0
0
The attached code works, apart from the area between the 2 sets of "---------------" lines; specifically I think lines labelled 10 and 20.

The highlighted area of code splits the text using " " as delimiter, then splits any remaining hyphenated words by "-" as delimiter, but retains the hyphen, on one or other of the resulting 'words'.

The problem is that although it displays the correct words in InkEditBox 2, it overwrites the value of articleSpltArr(j) with the value of hyphenWordArr(1), and loses the original string value at that value of j. Not what I had in mind.

I had thought that redimming the array as I have done would preserve the original value, add another string to the array, and make that one = hyphenWordArr(1). But this isnt what's happening.

hyphenWord and hyphenWordArr only exist to help performing the split; they aren't needed for anything else.

Short of putting hyphenWordArr(1) and articleSpltArr(j)'s values into a third array, what can I do to make this work properly?

Attached code and test file, and rtf of form1.frm

Thanks
Attached Files
Viewing all 21096 articles
Browse latest View live


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