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

Using Datepart and Dateserial in SQL query

$
0
0
hello,

I trying to execute the following sql query on Access database, to get those records which have DOB (a date) greater than 7 days than datetill (a Date)

Bdaystr = "Select * From MemberRegister Where DateDiff(" & "'" & "d" & "'" & ",#" & datetill & "#, DateSerial(" & curyear & ",DatePart(" & "'" & "m" & "'" & ",DOB),DatePart(" & "'" & "d" & "'" & ",DOB))) >= 7 ;"

I am getting error data type mismatch.

application hang problem

$
0
0
I have code below to check for piracy of my software. Though it is not the best out there but perhaps way to make it harder or annoying to be pirated.

Code:

Public Sub CheckForPiracy(num As Long)
    Dim PauseTime, Start
    PauseTime = num 
    Start = Timer 
   
    Do While Timer < Start + PauseTime
        DoEvents  ' Yield to other processes.
    Loop
   
    Call chknw  'This will check if the license is available, expired o correct.  If not, shutdown the
   
    Dim i As Long
    i = RandomNumber(7200, 300)
    CheckForPiracy(i)              'repeat the procedure
End Sub

I call the above procedure on mdiform form_activate event. But I notice that the toolbar on my mdiform hangs until I open up a new form where the whole app gui is refreshed.

chknw procedure is an if statement checking the existence of license file, comparing license from license file and checking expiry date from license file. I dont think this causes application to hang.

Can you advice me how I can optimize that code in order not to cause application hang.

.

Need VB code to view which subset appears most

$
0
0
Challenge:

The file Challenge.txtcontain a list of itineraries. Each row (or itinerary) contains a list of destinations separated by the char ";".

SUPER-HARD: find the 10 most frequent subset of destinations between all itineraries (regardless the subset size and ignoring size 1)and give the amount of times each subset appears on the dataset.

Example of expected output (each letter is a destination):

1. AB: 1000
2. ACD: 500
3. ABCD: 100
4. AFD: 50
5. AR: 20
6: ABCDEFG: 5
7: AFGP: 4
8: AT: 3
9: BN: 2
10: GT: 2

HARD: find the 10 most frequent size-n subset of destinations between all the itineraries and give the amount of times each subset appears on the dataset.

Example of expected output (each letter is a destination)AND given n= 3:


1. ABC: 1000
2. ACD: 500
3. ADE: 100
4. AFD: 50
5. ARE: 20
6: EFG: 5
7: AFP: 4
8: ATR: 3
9: BNK: 2
10: KGT: 2

HARD - : find the 10 most frequent size 3 subset of destinations between all the itineraries and give the amount of times each subset appears on the dataset.

Example of expected output (each letter is a destination) note: n is fixed to 3.


1. ABC: 1000
2. ACD: 500
3. ADE: 100
4. AFD: 50
5. ARE: 20
6: EFG: 5
7: AFP: 4
8: ATR: 3
9: BNK: 2
10: KGT: 2
Attached Files

[RESOLVED] Error in Using Option

$
0
0
Code:

Private Sub cmdPrint_Click()
If Opt1.Value = True Then
    Dim cnview As New ADODB.connection
    Dim rsview As New ADODB.Recordset

    Call connection(cnview, App.Path & "\Seeyou.mdb", "endromida")
    'Call connection(cnview, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
    Call Recordset(rsview, cnview, "SELECT * FROM fabric_shirt order by Fbcode asc")

    If rsview.RecordCount = 0 Then
    MsgBox "No Record Found On Query.", vbCritical, "Seeyou"
 
    Else
    Set fab_en.DataSource = rsview
    fab_en.Orientation = rptOrientLandscape
    fab_en.Show
    End If

    Set rsview = Nothing
Elseif
Opt2.Value = True
   
    Dim tcnview As New ADODB.connection
    Dim trsview As New ADODB.Recordset

    Call connection(tcnview, App.Path & "\Seeyou.mdb", "endromida")
    'Call connection(tcnview, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
    Call Recordset(trsview, cnview, "SELECT * FROM fabric_tro order by Fbcode asc")
   
    If trsview.RecordCount = 0 Then
        MsgBox "No Record Found On Query.", vbCritical, "Seeyou"
     
    Else
        Set fab_en.DataSource = trsview
        fab_en.Orientation = rptOrientLandscape
        fab_en.Show
    End If
   
    Set trsview = Nothing
End If
End If
End Sub

RESOLVED - multi search in txt files

$
0
0
Hi!

I have a problem with txt files.

There are may txt files in folder. I need to search a few string in txt files.

For example;

Within each file

"11.10.2016", alex martin, 123456789,500,2500,12000,"london","34100"
"19.12.2016", michael, 8500025122,1500,2500,12000,"paris","06000"
"11.10.2016", jason, 123456789,500,2500,12000,"new york","34100"
"19.12.2016", michael, 8500025122,1500,2500,12000,"paris","06000"

There are thousands of such records.


For example, it scans all .txt files in the folder in "19.12.2016", "12000" and "paris" words . Can I write to another txt file ?

sorry for english

Thank you

Gettting tab names in IE11

$
0
0
With the help of the API functions SendMessage, GetWndowLib, and GetClassName I can get the tab name of a specific IE 11 tab, if it is active. But if the tab I need is not active, how do I get it. How do I tell if the tab is not there at all.

Thanks

[RESOLVED] Gettting tab names in IE11

$
0
0
With the help of the API functions SendMessage, GetWndowLib, and GetClassName I can get the tab name of a specific IE 11 tab, if it is active. But if the tab I need is not active, how do I get it. How do I tell if the tab is not there at all.

Thanks

Change to defaults

$
0
0
Hello

My preferred font on all vb6 forms, controls etc. is Microsoft Sans Serif 10 point bold (and not MS Sans Serif 8pt regular).

Is there any way I can reset the defaults of these so that the IDE opens with them already selected?

Thanks

Components could not be loaded

$
0
0
Hi

I am trying to select component mscomctl.ocx it gives message

'' Could not be loaded .

Secondly on some components it gives message "Object control could not be loaded".

I am using Windows7 Professional 32 bit.

Thanks

how to query to list range dates

$
0
0
This involve to table field to query a result but I would like to list in rows a result of sql query between two dates. Im using mysql. I been thinking awhile now, i cant have idea of what statement to use.

I tried select curdate() as mycurdate where curdate() between '2001-01-01' and '2001-12-31' but I got error statement error.

I have hoping to have result

|mycurdate|
2001-01-01
2001-01-02
2001-01-03
.
.
.
2001-12-31

JavaScript execution via VB

$
0
0
Hi All,
Please need your kind assistance here with a code

I am trying to automate the way we send bulk/free sms using way2sms.com. Basically I have coded a VB form with a webbrowser and I

I am reached a point where I am able to login. But i am struck here as I need to click a button "Send Free SMS" which is a javascript button click event. I have put the page source below,

wb.Navigate("http://site23.way2sms.com/content/index.html")
While wb.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
End While

wb.Document.GetElementById("username").SetAttribute("value", "Mobile-number")
wb.Document.GetElementById("password").SetAttribute("value", "password")
wb.Document.GetElementById("loginBTN").InvokeMember("click")

Dim doc As mshtml.IHTMLDocument2 = wb.Document.DomDocument

htmlDoc = wb.Document.DomDocument

htmlColl = htmlDoc.getElementsByTagName("input")
wb.Document.InvokeScript("javascript:goToMain('s');") /// its not invoking the script. I have tried multiple things none working for me. Please assist

tried
wb.Navigate(New Uri("javascript:(function(){ javascript:goToMain('s'; })();"))/// this also dint work

For Each htmlInput In htmlColl
If htmlInput.onclick = "function onclick()" & Chr(10) & "{" & Chr(10) & "javascript:goToMain('s');" & Chr(10) & "}" Then //this also dfint work
'htmlInput.FireEvent("onclick")
end if

Next





The way "Send Free SMS" java class is declared is shown below
----------------------------------------------------------------------------------




<div class="lans">
<div class="lan sms">
<h3>Send SMS</h3>
<p>Send Free SMS to any mobile number in India. More than 90% of messages are delivered under 10 seconds.</p>
<input type="button" onclick="javascript:goToMain('s');" class="button br3" value="Send Free SMS" />
</div>

Accessibility and VB6 user controls (supporting screen readers, etc)

$
0
0
I've tried searching the forums for information on adding accessibility features to VB6 user controls, but the results are pretty slim (and 15 years old!).

So out of curiosity - are there any accessibility experts out there? I'd like to do a better job of supporting tools like screen readers with various user controls I've built over the years, but the MSDN documentation on accessibility is... complicated, to say the least. There are also two different accessibility toolkits: the ancient IAccessible COM interface, and the newer UI Automation toolkit for Vista+. That "new" UI Automation toolkit seems like the better choice, but support is probably limited to Windows 7 or later per this MSDN page:

Quote:

UI Automation was first available in Windows XP as part of the Microsoft .NET Framework. Although an unmanaged C++ API was also published at that time, the usefulness of client functions was limited because of interoperability issues. For Windows 7, the API has been rewritten in the Component Object Model (COM).
I'm no COM expert, but given the excellent work others have done on dragging VB into the modern era with updated typelibs (paging fafalone!), maybe this is an interface to add to the project list? I believe the heart of the new accessibility system is the IUIAutomation interface (which is enormous). Maybe this is too much, I don't know.

Regardless, many thanks to anyone who can offer any expertise on this subject.

Convert 8bit Wav to 16Bit wav

$
0
0
Hello,

Assuming we have our 8Bit wav loaded in a bytearray.
How can I convert this to 16bit and save out as 16bit ?

[RESOLVED] Run time Error 3709

$
0
0
Code:

Private Sub cmdPrint_Click()
If Opt1.Value = True Then
    Dim cnview As New ADODB.connection
    Dim rsview As New ADODB.Recordset

    'Call connection(cnview, App.Path & "\Seeyou.mdb", "endromida")
    Call connection(cnview, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
    Call Recordset(rsview, cnview, "SELECT * FROM fabric_shirt order by Fbcode asc")

    If rsview.RecordCount = 0 Then
    MsgBox "No Record Found On Query.", vbCritical, "Seeyou"
 
    Else
    Set fab_en.DataSource = rsview
    fab_en.Orientation = rptOrientLandscape
    fab_en.Show
    End If

    Set rsview = Nothing
Else
If Opt2.Value = True Then
   
    Dim tcnview As New ADODB.connection
    Dim trsview As New ADODB.Recordset

    Call connection(tcnview, App.Path & "\Seeyou.mdb", "endromida")
    'Call connection(tcnview, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
    Call Recordset(trsview, cnview, "SELECT * FROM fabric_tro order by Fbcode asc")
   
    If trsview.RecordCount = 0 Then
        MsgBox "No Record Found On Query.", vbCritical, "Seeyou"
     
    Else
        Set fab_en.DataSource = trsview
        fab_en.Orientation = rptOrientLandscape
        fab_en.Show
    End If
   
    Set trsview = Nothing
End If
End If
End Sub

Getting for 2nd Option, The connection cannot be used to perform this operation.its either closed or invalid in this context

2tables Data in one report

$
0
0
Code:

Private Sub cmdPrint_Click()
Dim cnview As New ADODB.connection
Dim rsview As New ADODB.Recordset

Call connection(cnview, App.Path & "\Seeyou.mdb", "endromida")
'Call connection(cnview, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
Call Recordset(rsview, cnview, "SELECT * FROM fabric_tro inner join fabric_shirt on fabric_tro.sup = fabric_shirt.sup")

If rsview.RecordCount = 0 Then
    MsgBox "No Record Found On Query.", vbCritical, "Seeyou"
 
Else
    Set fab_en.DataSource = rsview
    fab_en.Orientation = rptOrientLandscape
    fab_en.Show
End If

Set rsview = Nothing
End Sub

This code is not working? why?

Copying folders with subfolders. Too good to be true?

$
0
0
I have a large folder with many subfolders, some holding other subfolders and all holding files. I wanted to automate copying the main folder to another location, keeping all the structure intact.

Many searches showed solutions including recursive routines. This is a sample (may have typing errors but the point is to show the recursion suggested)

Code:

Public fso As FileSystemObject
Private Sub Command1_Click
    Dim fldr As Folder
    Set fso CreateObject("Scripting.FileSystemObject")
    Set fldr = fso.GetFolder("[destination here]")
    GetFiles fldr
    Set fso = Nothing
End Sub

Private Sub GetFiles(MyFldr As Folder)
    Dim subfldr As Folder
    Dim fls As Files
    Dim fl As File
    Set fls = MyFldr.Files
    For Each fl in fls
        fso.Copyfile fl.Path, [destination], True
    Next
    For each subfldr in MyFldr.SubFolders
        Call GetFiles(sbfldr) 'the recursion?
    Next
End Sub

However, I found another suggested solution, which I am trying experimentally and it seems to work perfectly. Apparently fso.CopyFolder does look after all the subfolders, and the structure appears to copy OK. I am wondering what the catch is and if there is none why the other 'experts' made it unnecessarily complicated. The code is

Code:

Dim fso As New Scripting.FileSystemObject
fso.CopyFolder "[origin here]", "[destination here]", True

Of course, in both cases Microsoft File Scripting Runtime is added to references

what vb6 component is this ?

$
0
0
what vb6 component is this ?
Attached Images
 

Clikc ok button on dialog box opening in webbrowser

$
0
0
Hello,

I am new to VB6 and have to modify some code.

My program loads a web page in webbrowser control and data is filled automatically
when Ok button is clicked a dialog box is poped up

I want to automate clicking ok button of the dialog box

The web page code is as below

<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable" tabindex="-1" role="dialog" aria-describedby="dialog" aria-labelledby="ui-id-1" style="display: none; position: relative;"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix ui-draggable-handle"><span id="ui-id-1" class="ui-dialog-title">Please confirm your CID / ID</span><button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" title="Close"><span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">Close</span></button></div><div id="dialog" style="" class="ui-dialog-content ui-widget-content">
CIN / ID <input type="text" name="cidnum" maxlength="12" value="" class="form101_textf" id="cidnum">
<br><br>

My code autofills this data

WebBrowser1.Document.getElementById("cidnum").Value = dbftin


But I am unable to get id of ok button or find the window handle to pass tab and then enter key

I have tried using sendkeys but get permission denied message

Please help
Thanks in advance

Invalid Picture error in Picture box

$
0
0
Hello all,

I am downloading a picture from website using

URLDownloadToFile(0, img.src, imagenm, 0, 0)

The file is downloaded perfectly and can be opened in mspaint ok

But when i try to set it as picture of picture box control i get error

Invalid Picture

1) If i reopen manually in paint and save it as 16 bit image then i can add it as picture
- can i auto download picture in format which is readable by vb6
i have tried all formats bmp/jpeg/gif
OR

2) If i use following code :

Set O = WebBrowser1.Document.body.createControlRange()
Call O.Add(WebBrowser1.Document.All("mycompanyimagedata"))
Call O.execCommand("Copy")
Set frmcapimg.Picture2.Picture = Clipboard.GetData

All works ok but my webbrowser gives error copy/paste not allowed
is there any other way to set image to clipboard

Thanks in advance as i am new to vb6 any help is very much appreciated

Is there a place to download OCX files?

$
0
0
I have a VB6 project that needs to be updated, and when I load it into VB6 on an Xp machine it says it can't find some OCX files. I'm not sure if these were 3rd party or from a very old Microsoft VB version (this company has been using VB forever).

Missing files are GRID32.OCX, GRAPH32.OCX, and PDQCOM32.OCX. I think the last one was a precursor to MSCOMM32 but I'm not sure.

Is there a web site somewhere where I can get these?

Thanks.
Viewing all 21323 articles
Browse latest View live


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