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

Vb6 + adodc

$
0
0
Hi im just starting to learn about vb6, and I am working with some assignments. I need some help on how to delete records in vb6 using adodc and delete query? This is my code

Dim sql as String
sql = Delete from users where ID=' " + txtId.Text + " ' "
adodc1.CommandType = adCmdText
adodc1.RecordSource = sql
Set DataGrid1.DataSource = adodc1

This code is not functioning, but when i replaced the query as for displaying a record as select* from users it's working. Can someone help me? Thanks in advance.

Version Control Application VB6

$
0
0
need a starting point basically needs to be able to back up a file/s or folders, check in check out, control users and version control, lock if user has the files out, report let them know who, central archive if need to roll back, etc etc any help on some source files to get me started.

Bringing Core Audio to VB6.. various obstacles

$
0
0
So I'm preparing to expand my typelib project by bringing in all of the CoreAudio interfaces. Some of the interfaces are easy to deal with-- I've already got working demos to list all devices with MMDeviceEnumerator, and using IMMDevice to get display names, and activate for IAudioEndpointVolume to adjust volume/mute/etc.

But some of the interfaces present challenges regarding how to convert to data types and pass parameters from the interface definition to VB.
Here's some of my outstanding questions I'd rather try to get an answer on instead of going the trial and error route:

1) There's lots of places where variable-length arrays are passed back to VB. An example is IChannelAudioVolume:
long GetAllVolumes([in] UINT32 dwCount,[out] float *pfVolumes);
is the official declaration from the SDK IDL. The count is known from an earlier call, so I can ReDim the array (of Single's right?) to the number of elements... but if I use sngArr(0) as pfVolumes, would it populate the other members? Or what about, would changing it to a Long give me a pointer from which I could use CopyMemory sngArr(0), ByVal pfVolumes, LenB(sngArr(0)) * dwCount ? Something else?

2) No idea how the first argument should really be passed; it's not a single byte for sure... should be equal to a return from GetNextPacketSize.. but it's the array issue again:
long GetBuffer(
[out] BYTE **ppData,
[out] UINT32 *pNumFramesToRead,
[out] DWORD *pdwFlags,
[out] UINT64 *pu64DevicePosition,
[out] UINT64 *pu64QPCPosition);


(example from IAudioCaptureClient)

3) Haven't really had to worry about it before... but UINT32 is all over the place; what happens if it exceeds the value of VB's (signed) Long when it's passed to a function?


..will post more questions as I expand the demos, but it's coming along... right now all the buttons pictured work as indicated:


and all the interfaces have been added as vb-addressable (so just minor adjustments if any still need to be done) to the TLB, all PKEYs, IIDs, GUIDs and consts are in a module

example:
Code:

Dim sOut As String
Dim i As Long

Dim pDvEnum As MMDeviceEnumerator
Set pDvEnum = New MMDeviceEnumerator

Dim pDvCol As IMMDeviceCollection

pDvEnum.EnumAudioEndpoints eAll, DEVICE_STATEMASK_ALL, pDvCol

If (pDvCol Is Nothing) = False Then
    Dim nCount As Long
    Dim pDev As IMMDevice
    Dim sStatus As String
    Dim nStatus As DEVICE_STATE
   
    If pDvCol.GetCount(nCount) = S_OK Then
        For i = 0 To (nCount - 1)
            pDvCol.Item i, pDev
            If (pDev Is Nothing) = False Then
                pDev.GetState nStatus
                sStatus = GetStatusStr(nStatus)
                sOut = sOut & "(" & sStatus & ") "
            End If
            sOut = sOut & "Device " & i & ": " & GetDeviceName(pDvCol, i) & vbCrLf
        Next
        Text1.Text = sOut
    Else
        Debug.Print "Failed to get device count."
    End If
Else
    Debug.Print "Failed to enum endpoints."
End If

REPLACE cahracter in MID string position

$
0
0
This is my little code to check a chr(12) in string

Code:

Option Explicit
Private Sub CERCA(A)

    Dim I As Long

    For I = 1 To Len(A)
        Debug.Print Mid(A, I, 1)
        If Mid(A, I, 1) = Chr$(12) Then Stop
    Next

End Sub

now i need to replace in mid position the chr(12) with a ""(blank/null) charracter...
How to?

outdated user interfaces

$
0
0
I was reading an article by a software reviewer regarding user interfaces. He showed examples of some really nice looking stuff, claiming it to be outdated. Now, to me, anything written back in the windows 3.0 era, is basically, outdated. So whats considered as 'Modern'?

error 429 cannot create activex component

$
0
0
Hi all,

I recently upgraded my system to Windows 10 and I reinstalled Visual Basic 6 (so it works in 64bit) successfully guided by this excellent web page :
http://blog.danbrust.net/2015/09/14/.../#.VzNJ-Y1X_ct

Today, I started the VB6 editor as (ADMINISTRATOR) and created a simple ActiveX dll Project to see if everything works properly
The ActiveX dll just displays a Msgbox upon initializing - No other code
Code:

Private Sub Class_Initialize()
    MsgBox "hello world"
End Sub

I renamed the ActiveX Project as TestProject and the Class as MyClass ( The Class Instancing MultiUse) and then compiled the dll successfully ... I saved the DLL Project in the following path : "C:\Test\"

Next step, I registered the dll (as Administrator) succesfully ... So far so good

Now, In order to test the newly created ActiveX dll, I ran this code from excel (64 bit office) :

Code:

Sub Test()
    Dim Obj As Object
   
    Set Obj = CreateObject("TestProject.MyClass")
End Sub

This is where I get the error mentioned in the post title ... I can't seem to instantiate the VB6 dll from Excel ... also tried it in MS Word - same problem

I tried Early binding as well but no joy .. I keep getting the 429 error

Can anybody shed some light on this ?

Thank you

Extra Space Between Records in Detail Section

$
0
0
I am using VB6 data report and want no space between the records as they are printed out.

I have already made sure all textbox tops are at "0" and the detail section is the same height as the text boxes.

Is there somewhere that the spacing between records can be set in the data report?

Any help will be appreciated.:)

Missing References

$
0
0
I have a VB6 app using Access 2003. I can easily run the 6 program. However, starting today (5/11/16) I cannot open the database directly. I believe I am missing some reference which do not show up in the reference dialog box. I have reinstall MS Office Pro 2003, always getting successful results. The missing references are Microsoft office 11.0 Object Library (Office 15.0 appears, but Office was never installed), Microsoft Forms 2.0 Object Library, Microsoft Calendar control 8.0(I don't think I need this), and Microsoft Windows Common Controls-2 6.0
The DB contains many forms and code behind.
How can I get these references back into the database for my VBA code?

Thanks

Listview Column Header BugFix

$
0
0
- How do I hover/hot focus listview column from code.
- How to click a column via code (when one clicks a manifested listview column header..it behaves like a button:: sunken and raised effect...how to do that via coding)

LucasMKG
?

How to set focus to "Find" form created by WebBrowser control?

$
0
0
I have VB6 form with MS Webbrowser control on it.
When I click the Webbrowser and after that press Ctrl+F the "Find" form pops-up. This "Find" form is created by Microsoft and is triggered by Webbrowser. I checked that "Find" form is not listed in the Forms collection.

Problem is - the focus of application usually is not switched to this "Find" form. It's title bar stays gray and user has to manually click it before typing the word he/she wants to find.

Can anyone advice me please how I can switch focus to this "Find" form immediately after it's pop-up.

Thanks!

[RESOLVED] Flexgrid change row color

$
0
0
Good Day!

Guys, I need your help. I want to change the color of the row depending on the condition. On my Form_Load it works well as you can see below :
Name:  FORM LOAD.jpg
Views: 37
Size:  55.6 KB

However if I'm going to search in my form the row color was not working already , see the the below pic:

Name:  SEARCH.jpg
Views: 44
Size:  29.2 KB

I want that even that there is a change with the data in the grid the row colors will still there depending on the condition I set for it. I try to put this code that I put in Form_Load in Change and Keypress Event but nothing happened, here's the code:

Code:

For i = 1 To invgrid.Rows - 1
         
         
            invgrid.Row = i
           
            If (Val(invgrid.TextMatrix(i, 6))) < (Val(invgrid.TextMatrix(i, 7))) Then
             
                For intCols = 0 To invgrid.Cols - 1
                    invgrid.Col = intCols
                    invgrid.CellBackColor = &HC0C0FF
                Next intCols
            ElseIf (Val(invgrid.TextMatrix(i, 6))) > (Val(invgrid.TextMatrix(i, 7))) Then
                    For intCols = 0 To invgrid.Cols - 1
                    invgrid.Col = intCols
                    invgrid.CellBackColor = &HC0FFFF
                Next intCols
            End If
           
           
Next i

To make more understable to all of you, here's the whole code of my form:

Code:


Private Sub Command3_Click()
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient

rs.Open "select * from View_ALL_INVENTORY " & _
"where FGID='" & Text1.Text & "' OR " & _
"DESCRIPTION like '%" & Trim(Text1.Text) & "%'", cn, 1, 3

End Sub

Private Sub Command1_Click()


If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient

rs.Open "select * from View_ActionDetailInventory where description like '%" & Text2.Text & "%' OR fgid like '%" & Text2.Text & "%' order by fgid", cn, 1, 3

Set invgrid.DataSource = rs
   
For i = 1 To invgrid.Rows - 1
         
         
            invgrid.Row = i
           
            If (Val(invgrid.TextMatrix(i, 6))) < (Val(invgrid.TextMatrix(i, 7))) Then
             
                For intCols = 0 To invgrid.Cols - 1
                    invgrid.Col = intCols
                    invgrid.CellBackColor = &HC0C0FF
                Next intCols
            ElseIf (Val(invgrid.TextMatrix(i, 6))) > (Val(invgrid.TextMatrix(i, 7))) Then
                    For intCols = 0 To invgrid.Cols - 1
                    invgrid.Col = intCols
                    invgrid.CellBackColor = &HC0FFFF
                Next intCols
            End If
           
           
Next i



End Sub

Private Sub Command11_Click()
Unload Me
End Sub

Private Sub Form_Load()
    Me.Left = (MDIForm1.ScaleWidth - Me.Width) / 2
    Me.Top = (MDIForm1.ScaleHeight - Me.Height) / 2


With invgrid

.Rows = 1
.Cols = 9

.Cell(flexcpText, 0, 1) = "F.G. ID"
.Cell(flexcpText, 0, 2) = "Description"
.Cell(flexcpText, 0, 3) = "UOM"
.Cell(flexcpText, 0, 4) = "Unit Price"
.Cell(flexcpText, 0, 5) = "Qty In"
.Cell(flexcpText, 0, 6) = "Qty Out"
.Cell(flexcpText, 0, 7) = "Total Stock"
.Cell(flexcpText, 0, 8) = "Current Stock"

.ColHidden(0) = True

.ColWidth(2) = 3500

End With

Call con
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient

rs.Open "select * from View_ActionDetailInventory order by fgid", cn, 1, 3


Set invgrid.DataSource = rs


For i = 1 To invgrid.Rows - 1
         
         
            invgrid.Row = i
           
            If (Val(invgrid.TextMatrix(i, 6))) < (Val(invgrid.TextMatrix(i, 7))) Then
             
                For intCols = 0 To invgrid.Cols - 1
                    invgrid.Col = intCols
                    invgrid.CellBackColor = &HC0C0FF
                Next intCols
            ElseIf (Val(invgrid.TextMatrix(i, 6))) > (Val(invgrid.TextMatrix(i, 7))) Then
                    For intCols = 0 To invgrid.Cols - 1
                    invgrid.Col = intCols
                    invgrid.CellBackColor = &HC0FFFF
                Next intCols
            End If
           
           
Next i
End Sub


Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub

Private Sub Option1_Click()
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient

rs.Open "select * from View_Inventory_SUPPLIES ORDER BY FGID", cn, 1, 3

Set invgrid.DataSource = rs
End Sub

Private Sub Option2_Click()
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient

rs.Open "select * from View_Inventory_RAWMAT ORDER BY FGID", cn, 1, 3

Set invgrid.DataSource = rs
End Sub

Private Sub Option3_Click()
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient

rs.Open "select * from View_Inventory_PACKMAT ORDER BY FGID", cn, 1, 3

Set invgrid.DataSource = rs
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Call Command3_Click
End Sub


Private Sub Text2_KeyPress(KeyAscii As Integer)
Call Command1_Click


End Sub

I'm sorry to confused you guys, but I badly need help right now.
Thank you so much.
Attached Images
  

MsgBox pop-up twice

$
0
0
Hi, Good day!

I have a problem with my msgbox it pop-up twice and it's very annoying. The problem with this it doesn't happen during IDE it happen only after I create a .exe for it. :confused:

After clicking the first item in NSDataCombo it will pop up a Msgbox , please see the pic below:

Name:  1st.jpg
Views: 50
Size:  34.9 KB

After clicking Yes/No it will pop-up again, like these :

Name:  2nd.jpg
Views: 49
Size:  27.0 KB

So I need to click Yes/No again and that it the time that the data will be populated in the grid, like these :

Name:  3rd.jpg
Views: 49
Size:  31.5 KB


Here's the code of change event of the NSDataCombo (the control that I'm using):

Code:

Private Sub NSDataCombo2_Change()
'=============AUTO LOAD PO DETAILS===============
If MsgBox("Do you want to load PO with barcode/item entry?", vbQuestion + vbYesNo, "RECEIVING") = vbNo Then




    Label15.Caption = "1"
   
    Call LoadDate
    txtPO.Text = NSDataCombo2.getSelValueAt(1)
    'DTPicker2.Value = NSDataCombo2.getSelValueAt(4)
    Text9.Text = NSDataCombo2.getSelValueAt(6)
    Label17.Caption = NSDataCombo2.getSelValueAt(8)
   
    LoadAllItem2 txtPO.Text
    Text9.Locked = True
    Text11.Locked = True
   
    Command6.Enabled = True 'insert button
    Command7.Enabled = True
   
    Label12.Caption = "1"
   
    CANDYBUTTON2.Enabled = False
    cmdSave.Enabled = True
    cmdaddfreegoods.Enabled = True
    Command9.Enabled = True
   
    txtbarcode.Enabled = False
    txtrrqty.Enabled = False
   
   
    rrgrid.Enabled = True



'============MANUAL ENTRY====================
Else
    txtPO.Text = NSDataCombo2.getSelValueAt(1)
    Text9.Text = NSDataCombo2.getSelValueAt(6)
    Text11.Text = NSDataCombo2.getSelValueAt(7)
    Text10.Text = NSDataCombo2.getSelValueAt(3)
   
    txtbarcode.Enabled = True
    txtrrqty.Enabled = True
    CANDYBUTTON2.Enabled = False
    cmdSave.Enabled = True
    Command9.Enabled = True
    Frame3.Enabled = True
    rrgrid3.Visible = True
    rrgrid3.Enabled = True
    rrgrid.Visible = False
    cmdaddfreegoods.Enabled = True
   
    Label15.Caption = "1"
    NSDataCombo2.DisableDropdown = True
   
    With rrgrid3
   

   
        If .Rows <= 5000 Then
              .Rows = .Rows + 1
              .Select .Rows - 1, 1, .Rows - 1, 1
              .EditCell
   
        End If
    End With
    End If


End Sub

Thank you :confused:
Attached Images
   

How to call keyboard buttons

$
0
0
Hello
I need to use the keyboard buttons to perform some tasks.
Is there a way to do that.
For example I want to use the Enter button to call save click and return button to return to the main form and the four arrows buttons to do other tasks.
Please tell me ho to do that
Thank you

Public holiday or trade day...

$
0
0
Hi !

For my program, intended for house holding economy, I'll try to make an automatic budgeting routine.

But to avoid public holidays and similar as payment days, I've make some tables for swedish holidays during a couple of years ahead, as some of them occures on different dates and/or week days.

However, assume that my program will be found by someone in an other contry, and this user even will make a good budget för the next year. He or she then have no use for calculating of swedish holidays.....

So I wonder, is there any API or other solutions for finding out if a certain date is a trade day or a public holiday - quite apart from weekends (saturdays and sundays) ?

This solution should be country specific, depending on the computer setting in that certain country, but using the same formula:

(If Date is a Trade day then....) or similar....

Just asking....

/Kalle

Undo Save

$
0
0
Some one please tell me there is a way to undo a save. i just made a huge mistake and and hit cut instead of copy on my code , then forgot about it and closed it and it asked me to save the changes and i did? now all my code is gone

ADO Recordset and Updateable View

$
0
0
Hi All,

Using VB6 SP6 with ADO 2.7 connecting to a SQL Server 2008 R2 database.

Attempting to work with an updateable view accessed through the ADO Recordset object. Experiencing unexpected behaviour as outlined below after opening recordset using:

rsD.Open sqlD, cn, adOpenStatic, adLockOptimistic

When I use the Find method, I receive 'Rowset does not support scrolling backward.' If at this point I try to step through the Find method again, it works.

If I test for EOF it returns True, even though I know the Recordset (before or after using Find) contains data.

Lastly, when I attempt to set the value of a column in the Recordset, I receive 'Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.'

The updateable view contains logic (triggers) to handle new data (inserts) and modifications (updates) and has been tested thoroughly, so at this point I'm thinking it has something to do with the ADO interface, most likely myself accessing it incorrectly.

Thoughts?

Any and all assistance is greatly appreciated!

Best Regards
Brad

arrgg... having a prob with a public Dim

$
0
0
going brain dead here.... Here's what im trying to do,

I want Form1 to remember a string. Lets say strA = "Hello"

Now i want Form2 to show that string in Label1. So Label1.Caption = strA

I could put in Form1 this.. Form2.Label1.Caption = strA

But, Form2 isnt open yet. When the user does open Form2, i want it to check strA and display it in Label1.

OK, should be easy, but its not working out. I tried putting Dim strA As String in a module, but it dont work.

ideas?

Day Of a date

$
0
0
Hi

I am getting user enter 2 dates . From date & To Date.

Day should always be 1 in From date.
Day should always be end date of the month of To Date

Thanks

WinHttp and Https

$
0
0
Hello,

I want to use an SSL connection. My webhosts (Ovh.com) give an SSL shared. I can use a connection like https://ssl3.ovh.net/~mylogin/... without password and login. Just to secure data

Code:

dim sURL as string
sURL="http://www.mydomain.com/page.php"

Dim xhr As Object
Set xhr = CreateObject("WinHttp.WinHttpRequest.5.1")

If xhr Is Nothing Then Set xhr = CreateObject("WinHttp.WinHttpRequest")
If xhr Is Nothing Then Set xhr = CreateObject("MSXML2.ServerXMLHTTP")
If xhr Is Nothing Then Set xhr = CreateObject("Microsoft.XMLHTTP")
xhr.open "POST", sURL, False 'True = async

xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.setRequestHeader "Content-Length", Len(Parameters)
xhr.send " param=abcd&param2=toto"
If xhr.Status = 200 Then
        'getBalance = xhr.responseText
       
ElseIf xhr.Status = 402 Then
       
End If

With a "http" is work fine but when I would like to uses the SSL url I have an error "Error -2147012867 (800072efd) "A connection with the server could not be etablished"
Maybe I can't use a HTTPS ?
thanks for any help !
Name:  ssl.jpg
Views: 37
Size:  21.4 KB

NB : If I test the https.. on my browser it's okay :/
Attached Images
 

test

$
0
0
I posted a fairly long one but it has not appeared in the threads..... Just testing
Viewing all 21588 articles
Browse latest View live


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