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

[RESOLVED] Connection Test

$
0
0
Hi

Below is my test connection . I want if it is successful it should return .T. else
.F.

Public Sub ConnectionTest()
Set cnn2 = New ADODB.Connection
On Error GoTo errhandler

' On Error Resume Next
cnn2.Open "Driver=SQL Server;Server=" & ServerName & ";Database=" & "Test" & ";uid=" & uid & ";pwd=" & pwd & ";"


If cnn2.State = adStateOpen Then

Else
MsgBox "Connection Failed", vbExclamation
End If
Exit Sub

errhandler:
If err.Number <> 0 Then

MsgBox err.Number & err.Description & err.Source

End If

Thanks

Help Logging in with WinSck...(Cookies)

$
0
0
Hi, I havent programmed in years... I just came home..anyways I downloaded vb6 and im picking it back up fairly quickly..heres my problem:

To login to this website with Inet or WebBrowser..you go here:
Quote:

aol.easports.com/common/login/login.jsp?site=eaco&finalredr=http%3A%2F%2Faol.easports.com%2Ffree%2F&skin=eacom
and it redirects you to here automatically

Notice the "ParsID" thats the problem... thats the cookie and since everytime you go to the first link you get a new one and in inet and webbrowser it automatically saves it..in winsck when you go to first link it doesnt automatically save the cookie you grab

When i do a "GET" I get cookies like this:

Set-Cookie: p.JID=12F354BDCCBF5CF7ECF9E119C8BE5F27.144056; Path=/
Set-Cookie: p.JID=1416DF4F4CAA725E94A7C363AE855369.144056; Path=/

Which doesn't make much sense, but either way I have no clue what to do to login with winSck, if anyone could post the code and explain it to me I would appreciate it very much.

I remembered years ago I figured it out and all I did was copy n paste the cookie but it was a different login method and im so rusty I forgot what I did...

Thanks in advance for your help!

P.S. Because this is a backdoor login when you enter the correct password it goes back to the login page and when you enter the wrong password it goes to a different website (this login is really old)

An account to use would be Username: AsdfNuke4 Password: 12345

Receiving run-time error on run, but not in debug

$
0
0
Hi all,

Long time lurker, first time... well, yeah.

Having a slight issue with a VB6 application I'm writing for work. So far, I have the application logging into a hidden webbrowser control, running a POS report, and then comes my issue.

On the HTML page, there is a dropdown box which contains a few export options to choose from, and a hyperlink next to it to run the export. If I run my application, I receive a Run-time error '91': Object variable or With block variable not set error.
I run the application in step-through mode to replicate the fault, but everything goes smoothly and export is completed. After that, if I run the application again, it goes through fine. It seems to be only happening before I debug, and then everything sorts itself out.

Can anyone offer any assistance?

This is the section of code containing the problem...

Code:

    'Load ClickPOS report 1-6 "Total Sales Grouped by Branch and Sales Rep"
    wb1.navigate ClickPosReport
    'Run wait event for full document completion
    waitForPageLoad
   
    'Set value of dropdown box to EXCEL
    Dim formExport As MSHTML.HTMLSelectElement
   
    Set formExport = clickPos.getElementById("ReportViewer1_ctl01_ctl05_ctl00")
    formExport.Value = "EXCEL"
   
    'Target 'Export'link next to dropdown and click
    Dim formExportButton As MSHTML.HTMLAnchorElement
    Set formExportButton = clickPos.getElementById("ReportViewer1_ctl01_ctl05_ctl01")
    formExportButton.Click

The line causing the run-time error is:

Code:

    Set formExport = clickPos.getElementById("ReportViewer1_ctl01_ctl05_ctl00")

Type libraries: Possible to have PROPVARIANT in a typelib vb6 can use?

$
0
0
As my other posts have been about lately, I'm using type libraries to expose modern shell interfaces in VB6. There's been some challenges, but I don't have near the amount of expertise to even attempt a solution to this;

The IShellItem2 interface, which allows you to access file properties, uses the following method:
HRESULT GetProperty([in] PROPERTYKEY key, [out] PROPVARIANT *ppropvar);

The PROPVARIANT structure, however, is like nothing I've ever seen before. The VT_ items are just constants, which I have an existing enum for (all?) them.
Code:



struct tag_inner_PROPVARIANT
{
    VARTYPE vt;
    PROPVAR_PAD1  wReserved1;
    PROPVAR_PAD2  wReserved2;
    PROPVAR_PAD3  wReserved3;
    [switch_is((unsigned short) vt)] union
    {
        //
        // Basic Types.
        //
        [case (VT_EMPTY, VT_NULL)]  ;
        [case (VT_I1)]              CHAR            cVal;      // New
        [case (VT_UI1)]            UCHAR            bVal;
        [case (VT_I2)]              SHORT            iVal;
        [case (VT_UI2)]            USHORT          uiVal;
        [case (VT_I4)]              LONG            lVal;
        [case (VT_UI4)]            ULONG            ulVal;
        [case (VT_INT)]            INT              intVal;    // New
        [case (VT_UINT)]            UINT            uintVal;  // New
        [case (VT_DECIMAL, VT_I8)]  LARGE_INTEGER    hVal;      // Decimal
        [case (VT_UI8)]            ULARGE_INTEGER  uhVal;
        [case (VT_R4)]              FLOAT            fltVal;
        [case (VT_R8)]              DOUBLE          dblVal;
        [case (VT_BOOL)]            VARIANT_BOOL    boolVal;
        [case (VT_ILLEGAL)]        _VARIANT_BOOL    bool;      // obsolete
        [case (VT_ERROR)]          SCODE            scode;
        [case (VT_CY)]              CY              cyVal;
        [case (VT_DATE)]            DATE            date;
        [case (VT_FILETIME)]        FILETIME        filetime;
        [case (VT_CLSID)]          CLSID *          puuid;
        [case (VT_CF)]              CLIPDATA *      pclipdata;
        [case (VT_BSTR)]            BSTR            bstrVal;
        [case (VT_BSTR_BLOB)]      BSTRBLOB        bstrblobVal; // System use only
        [case (VT_BLOB, VT_BLOB_OBJECT)] BLOB        blob;
        [case (VT_LPSTR)]          LPSTR            pszVal;
        [case (VT_LPWSTR)]          LPWSTR          pwszVal;
        [case (VT_UNKNOWN)]        IUnknown *      punkVal;    // New
        [case (VT_DISPATCH)]        IDispatch *      pdispVal;  // New
        [case (VT_STREAM, VT_STREAMED_OBJECT)] IStream*  pStream;
        [case (VT_STORAGE, VT_STORED_OBJECT)]  IStorage* pStorage;
        [case (VT_VERSIONED_STREAM)]  LPVERSIONEDSTREAM  pVersionedStream;

        //
        // Arrays of types  (only the old VARIANT types)
        //
        [case (VT_ARRAY|VT_I1,
              VT_ARRAY|VT_UI1,
              VT_ARRAY|VT_I2,
              VT_ARRAY|VT_UI2,
              VT_ARRAY|VT_I4,
              VT_ARRAY|VT_UI4,
              VT_ARRAY|VT_INT,
              VT_ARRAY|VT_UINT,
              VT_ARRAY|VT_R4,
              VT_ARRAY|VT_R8,
              VT_ARRAY|VT_CY,
              VT_ARRAY|VT_DATE,
              VT_ARRAY|VT_BSTR,
              VT_ARRAY|VT_BOOL,
              VT_ARRAY|VT_DECIMAL,
              VT_ARRAY|VT_DISPATCH,
              VT_ARRAY|VT_UNKNOWN,
              VT_ARRAY|VT_ERROR,
              VT_ARRAY|VT_VARIANT)]  LPSAFEARRAY      parray;    // New

        //
        // Vectors of types
        //
        [case (VT_VECTOR|VT_I1)]      CAC          cac;      // new
        [case (VT_VECTOR|VT_UI1)]      CAUB          caub;
        [case (VT_VECTOR|VT_I2)]      CAI          cai;
        [case (VT_VECTOR|VT_UI2)]      CAUI          caui;
        [case (VT_VECTOR|VT_I4)]      CAL          cal;
        [case (VT_VECTOR|VT_UI4)]      CAUL          caul;
        [case (VT_VECTOR|VT_I8)]      CAH          cah;
        [case (VT_VECTOR|VT_UI8)]      CAUH          cauh;
        [case (VT_VECTOR|VT_R4)]      CAFLT        caflt;
        [case (VT_VECTOR|VT_R8)]      CADBL        cadbl;
        [case (VT_VECTOR|VT_BOOL)]    CABOOL        cabool;
        [case (VT_VECTOR|VT_ERROR)]    CASCODE      cascode;
        [case (VT_VECTOR|VT_CY)]      CACY          cacy;
        [case (VT_VECTOR|VT_DATE)]    CADATE        cadate;
        [case (VT_VECTOR|VT_FILETIME)] CAFILETIME    cafiletime;
        [case (VT_VECTOR|VT_CLSID)]    CACLSID      cauuid;
        [case (VT_VECTOR|VT_CF)]      CACLIPDATA    caclipdata;
        [case (VT_VECTOR|VT_BSTR)]    CABSTR        cabstr;
        [case (VT_VECTOR|VT_BSTR_BLOB)]CABSTRBLOB    cabstrblob; // System use only
        [case (VT_VECTOR|VT_LPSTR)]    CALPSTR      calpstr;
        [case (VT_VECTOR|VT_LPWSTR)]  CALPWSTR      calpwstr;
        [case (VT_VECTOR|VT_VARIANT)]  CAPROPVARIANT capropvar;

        //
        // ByRefs of types.
        //
        [case (VT_BYREF|VT_I1)]      CHAR*          pcVal;      // New
        [case (VT_BYREF|VT_UI1)]      UCHAR*          pbVal;      // New
        [case (VT_BYREF|VT_I2)]      SHORT*          piVal;      // New
        [case (VT_BYREF|VT_UI2)]      USHORT*        puiVal;      // New
        [case (VT_BYREF|VT_I4)]      LONG*          plVal;      // New
        [case (VT_BYREF|VT_UI4)]      ULONG*          pulVal;      // New
        [case (VT_BYREF|VT_INT)]      INT*            pintVal;    // New
        [case (VT_BYREF|VT_UINT)]    UINT*          puintVal;    // New
        [case (VT_BYREF|VT_R4)]      FLOAT*          pfltVal;    // New
        [case (VT_BYREF|VT_R8)]      DOUBLE*        pdblVal;    // New
        [case (VT_BYREF|VT_BOOL)]    VARIANT_BOOL*  pboolVal;    // New
        [case (VT_BYREF|VT_DECIMAL)]  DECIMAL*        pdecVal;    // New
        [case (VT_BYREF|VT_ERROR)]    SCODE*          pscode;      // New
        [case (VT_BYREF|VT_CY)]      CY*            pcyVal;      // New
        [case (VT_BYREF|VT_DATE)]    DATE*          pdate;      // New
        [case (VT_BYREF|VT_BSTR)]    BSTR*          pbstrVal;    // New
        [case (VT_BYREF|VT_UNKNOWN)]  IUnknown **    ppunkVal;    // New
        [case (VT_BYREF|VT_DISPATCH)] IDispatch **    ppdispVal;  // New
        [case (VT_BYREF|VT_ARRAY)]    LPSAFEARRAY*    pparray;    // New
        [case (VT_BYREF|VT_VARIANT)]  PROPVARIANT*    pvarVal;    // New
    };
};

It doesn't even accept the first line. I changed it to the standard typedef enum PROPVARIANT.
The errors start at [switch_is((unsigned short) vt)] union -- obviously this kind of thing isn't allowed in vb6 type libs. Is there any way I can make this work? At least to return basic data types like numbers or a pointer to a string or an actual bstr; which would cover most properties anyway.

how to programatically close outlook model pop up in vb6.0?

$
0
0
Hello,

how to programatically close outlook model pop up in vb6.0?

Thanks,
Krunal

[RESOLVED] comic strip of the day?

$
0
0
Hi,

I´m new to VB :)

I would like a code to generate a "comic-strip-of-the-day" that will random pick between some predefined strip numbers (for example 1-20) each day.

Let´s say that I have a 20 different comic-strips and would like to show one of them each day but in a random order. For example, sunday gets strip 17, monday gets strip 7, tuesay gets strip 3 and so on.

I could easally put all strips in the same directory like: c:\strips\strip1.jpg, c:\strips\strip2.jpg, c:\strips\strip3.jpg and so on. And further on, when I have produced more comic strips the number can easilly grow to perhaps 100 compic strips :)

Is this possible?

I found that the code below generate a integer from todays date:

Private Sub command1_click()
Dim i As Long
i = CLng(Date)
MsgBox i
End Sub

But today 14-04-15 generates 41744, how do I convert that to a random number between 1-20?

Would really appreciate some help here :)

Best regards from
Wretan

autorun a video inside windows media player?

$
0
0
Hi,

Got really nice help from Phill.W and SamOscarBrown last thread a couple of minutes ago so I make another question to this exellent forum :)


If I would make a form with a mediaplayer that will autoplay a specific URL, what´s wrong with my code below?
(just a samle with the standard wildlife.wmv below) :o

Private Sub WindowsMediaPlayer1_OpenStateChange(ByVal NewState As Long)
WindowsMediaPlayer1.url = "C:\Users\Public\Videos\Sample Videos\wildlife.wmv"
End Sub

If I run the code above, nothing happens and I can not press the play button. I would really like it to autorun the URL.

Thank you in advance!

Parsing for field does not work for values ending 0

$
0
0
Values in the LocCode field that are ending in zero do not come through after running this script.

E610 > come in as 0
E600 > come in as 0
E630 > come in as 0

All other values not ending with zero, come in just fine.

E325 > come in as 325
E445 > come in as 445


Code:

If Not rs.bof And Not rs.eof Then
Do While Not rs.eof
rsAppend.AddNew
rsAppend.Fields("Entity") = Right(rs.fields("LocCode").Value,3)
rsAppend.Update
rs.movenext
Loop

Any idea how to bring in the full string for string ending zero?

Setting a variable to a control doesn't transfer the .Tag property

$
0
0
I have the following:

Private CurrentPiece As ucPiece

Then in code I have:

Set CurrentPiece = ucWPiece(index)

Now...

ucWPiece(index).Tag = "KN"

But...

CurrentPiece.Tag = ""

Why doesn't the .Tag property get transfered over?

finding process by patch

$
0
0
i was wondring if we have a file patch like J:\pic\vbforum.exe
can we see if this file is running and if is running we get the process name?

Web Site Populate Help

$
0
0
I have an interesting problem I am writing some code to populate a website, I have managed to get most fields filled in but some box which are list boxes only fill with options after another field is manually filled in, even if fill by sending text to field it dosent activate the other fields would any one have any ideas

I can provide name of website www.dpd.co.uk but to get to function requires login which I cant provide

any advice

Problem with a function

$
0
0
This is a Keno game
Clicking the lblcredit switches between Currency and credit display based on the the bet mode
5 Bet modes:
1 cent
2 cent
5 cents
10 cents
25 cents.

try as might i cannot get it to display correctly.
Example how it should work:
1 cent mode:
credit displays $1.00 clicking the lblcredit displays 100
clicking again displays $1.00 again

2 cent mode
credit displays $1.00 clicking the lblcredit displays 50
clicking again displays $1.00 again


5 cent mode
credit displays $1.00 clicking the lblcredit displays 20
clicking again displays $1.00 again

10 cent mode
credit displays $1.00 clicking the lblcredit displays 10
clicking again displays $1.00 again

25 cent mode
credit displays $1.00 clicking the lblcredit displays 4
clicking again displays $1.00 again

Clicking the cmdbetmode cycles the bet mode
see attached small project
What am i doing wrong ?
Attached Files

How to include EXE in VB6

$
0
0
I realize this is an old thread, but I am looking for help.

I was to create an command line front end for several CL tools. I use VB6 because that is what I know, I am not a programmer, just know a little.

I want to be able to "embed" the exe's into my project so this is one exe. For example, DELPROF2, I can write it so that my exe is in the same dir as delprof2.exe, but I don't want to have 3-5 exes to have to be there.

Any help would be appriciated, like I said, I know a little, but not nearly enough. I looks at your example, I like it running in memory, but I am not sure how to modify it to add my exe.

Thanks!

Taskbar is disappeared when BorderStyle = Fixed Dialog

$
0
0
My project have 2 forms, form1 and form2.
form1 open form2 of which BorderStyle = Fixed Dialog and WindowState = Maximized.
Start point is form1.
If run program form1 is shown.
at this time, task bar is shown.
However, if open from2, taskbar is disappeared.
Can I prevent from this?
I attatched sample project.
You will see what happens(task bar is disappeared) if you click [Command1] button.
Attached Files

How To Edit Active Report Design At RUN TIME IN VB6 ?

$
0
0
I have Application With VB6 And Reports With Active Report
How Can I let user Edit Report Design At RUN TIME ? As he can Change Label font or left or top or color
can any one help me ? and Meany thanks for All .......

[RESOLVED] Adodc get Line( of the arrow row)

$
0
0
i can get the Row in adodc
i mean
if i use datagrid i can use datagrid to get the line of the row i stand on
but i can do it also in only adodc???

i mean
if i use adodc
and i move (next/prev) in the lines i can get which line i stand on??

Code help to search sheets in Excel

$
0
0
Hello All,
I need some help writing some VB code in Excel to search all worksheets in a workbook (excluding 2 of them) for a specific string. When that string is found in any of the worksheets, I want to place a specific value in the cell 8 columns to the right. I can adapt the code as needed, I just need to find out a general set of code to do this. Please help.

Thanks!

Do For Loop. ect

$
0
0
Like i've said before it's been forever since i coded, but i recently finished what ive been working on the last thing is to add a Loop...

Code:

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim data As String
Winsock1.PeekData data
RichTextBox1.Text = data
If InStr(data, "blah") Then
List3.AddItem (List1.Text & " " & List2.Text)
 
Else
List2.ListIndex = List2.ListIndex + 1
 
End If
 
End Sub

okay I need it to wrap around and try the next item in Listbox2.text until it reaches the end of the Listbox which varies

anyone know where and exactly what to put for the loop?

Pasting code in colour

$
0
0
hey i really need to paste some of my vb coding in a publisher doc but all the code is comming in black and white. i have like 50 forms to paste so colouring all the If then statements ad annotations will be a problem. Is there any way to do this or any new website that will do this for me please help.

how to create UserControl with DataSource (adodc datasourse)

$
0
0
i wanna to create UserControl
that get in properties (Set) Adodc
and every change in UserControl will change the DataSource
i mean i wanna create UserControl
that in properties The User choose which Datasourse(like in datagrid have DataSource)
and every change you do in the UserControl so the DataSource in the Form will be change

if can how i can add in the properties like the

Public Property Get DataSource() As Variant
DataSource = Adodc1
End Property

Public Property Let DataSource(ByVal vNewValue As Variant)
Set Adodc1 = vNewValue
End Property

how i can do that in the Form the choose for DataSource be from list (like comboBox)
like in the Datagrid the property of DataSource is searching for adodcs
Viewing all 21702 articles
Browse latest View live


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