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

How to run the command prompt per line in the textbox ?

$
0
0
Hello guys, I want to create a simple application to speed up tasks, by running the batch file via the command prompt. The application is used to merge the batch script file, the script is :
Code:

livestreamer "hlsvariant:// (Text1) " best -o (Text2).ts
Description : Text1 is where I put the source file link, and Text2 is where I put the name of file.

Then I made a visual basic script on code like this :
Code:

Private Sub Command1_Click()
Dim RetVal
BatchCode
RetVal = Shell("C:\Example.bat", vbNormalFocus)
End Sub
Sub BatchCode()
On Error Resume Next
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.createtextfile ("C:\Example.bat")
Open "C:\Example.bat" For Output As 1
Print #1, "@echo on"
Print #1, "livestreamer ""hlsvariant://" & Text1.Text & """ best - o " & Text2.Text & ".ts"
Print #1, ":end"
Close #1
End Sub

Name:  Zenm.png
Views: 30
Size:  118.1 KB
Name:  Zenn.png
Views: 31
Size:  161.7 KB

But after I run the application, it turns out the source link that I enter is processed in its entirety on Text1. Question : How do I process all the source link in line per line ? :rolleyes:

Sorry my bad English, :D Thank you ...
Attached Images
  

Problem with Standard DLL

$
0
0
Visual Basic doesn't normally create standard DLL library files, and I couldn't find any reference to such a utility in VBForums. So I searched and found an excellent AddIn from DanSoft Australia.
http://www.dansoftaustralia.net/developers/vb.htm
Once loaded as per the instructions, it adds a Standard DLL template to VB, as well as a menu item for creating the .def file. When compiled, the AddIn temporarily replaces the Linker to create the DLL.

And that's where I ran into this little problem. Everything works fine until I attempt to pass a string variable to the DLL. For example, this routine works just great when called as a simple function.
Code:

Private Declare Function BCryptOpenAlgorithmProvider Lib "bcrypt.dll" (ByRef hAlgorithm As Long, ByVal pszAlgId As Long, ByVal pszImplementation As Long, ByVal dwFlags As Long) As Long
Private Declare Function BCryptCloseAlgorithmProvider Lib "bcrypt.dll" (ByVal hAlgorithm As Long, ByVal dwFlags As Long) As Long

Function DLLMain(ByVal A As Long, ByVal B As Long, ByVal c As Long) As Long
    DLLMain = 1
End Function

Sub Main()
    'This is a dummy, so the IDE doesn't complain
    'there is no Sub Main.
End Sub

Function GetECC(ByVal sAlg As String) As Boolean
    lRet = BCryptOpenAlgorithmProvider(hProv, StrPtr(sAlg), StrPtr("Microsoft Primitive Provider"), 0)
    If lRet <> 0 Then
        GetECC = False
        GoTo ReleaseHandles
    End If
    GetECC = True
ReleaseHandles:
    If (hProv) Then BCryptCloseAlgorithmProvider hProv, 0
End Function

But when I run it as a standard DLL it fails with Error &HC0000225. If I change the function to:
Code:

Function GetECC(ByVal sAlg As String) As Boolean
    lRet = BCryptOpenAlgorithmProvider(hProv, StrPtr("ECDH_P256"), StrPtr("Microsoft Primitive Provider"), 0)
    If lRet <> 0 Then
        GetECC = False
        GoTo ReleaseHandles
    End If
    GetECC = True
ReleaseHandles:
    If (hProv) Then BCryptCloseAlgorithmProvider hProv, 0
End Function

it works just fine. Is there something different about the way DLLs handle string information. In this particular case the variable is required to be a double wide (ie. Unicode) string.

J.A. Coutts

Zero File lenth after uploaud bu INet Control

$
0
0
Hello every body

i have this ftp information

FTP username 0fe_16987593
FTP password 5050500
FTP host name ftp.0fees.us

and i have directory on the ftp pannel Named "work" in site created directory named "htdocs"

and i put file named "Mariam.exe" in "work" directory

when i test download this file by the foolowing code it give me zero lenth file on my hard desc


inetFTP.URL = "ftp://ftp.0fees.us/"
inetFTP.UserName = "0fe_16987593"
inetFTP.Password = "5050500"
inetFTP.Execute , "CD htdocs/work"



Do While inetFTP.StillExecuting
DoEvents
Loop


inetFTP.Execute "", "GET " & "Mariam.exe" & " " & "Mariam.exe"


Do While inetFTP.StillExecuting
DoEvents
Loop




inetFTP.Execute , "CLOSE"


when i replace actin GET by action PUT it successfully put the file on the internet put zero lenth also


please help

[RESOLVED] Updating A field OverwRites Existing one While Looping Why?

$
0
0
i have a listview that i loop and see if the same name exsits as in another table name
then i update the necessary update.
the problem is if there are 2 things that are the same
then it OverwRites the first update why?
this is the code i am using
Code:

Private Sub CheckAndUpdateMoadonPoints()
    Dim Rs As New ADODB.Recordset
    Dim StrPointCredit As String
    Dim StrPointName As String
    Dim StrCust As String
    Dim StrUpd As String
    Rs.Open "Select * From VipCustomers Where VipName = '" & RplS(TxtCustName.Text) & "'", CN
    If Rs.EOF Then
      Rs.Close
      Exit Sub
    Else
        StrCust = Rs!VipName
    End If
    Rs.Close
     
    Rs.Open "Select * From VipPoints", CN
    Do While Not Rs.EOF
        StrPointCredit = Rs!PointCredit
        StrPointName = Rs!PointGift
   
    Dim I As Integer
    For I = 1 To LsVw.ListItems.Count
    If LsVw.ListItems(I).SubItems(1) = StrPointName Then
        StrSql = "Update VipCustomers Set VipCredit = '" & StrPointCredit & "' Where VipName = '" & StrCust & "'"
        CN.Execute StrSql
    End If
    Next I
        Rs.MoveNext
    Loop
    Rs.Close
End Sub

tnx in advanced
salsa31

VB6 compiled on win 10 fails with VS2015 side-by-side DLL other OS's

$
0
0
I am trying to get our VB6 development environment up and running on windows 10 x64 (build 10240). The VB6 IDE install went without a hitch (H/T fortypoundhead!), as did all the third-party controls that we use.

The Win10-x64 system also has VS2015 Community Edition installed which we are using for related development and creating DLLs that are deployed side-by-side with the VB6 application (along with a manifest). This has worked great for several years when compiled on a win7-x64 system under vs2010 and VS2012.

What we have found is that the application works perfectly on win10 systems, but immediately fails when tested on win7(x32 or x64) or win10-32 bit. Applications that are pure VB6 work fine, but there appears to be an incompatibility introduced by the VS2015-compiled DLL. The DLL is compiled for "Any CPU" and targets the .net 4 runtime.

If I examine the VB6 EXE binary as compiled on a win7-64 system ("good") verses the win10-64 system("fails"), there are substantial differences even though the code and project settings are identical.

Anyway, I am looking for suggestions as to what to look for that may be causing this issue. Really don't know if this is a Win10 or VS2015 issue - or, something else entirely!

Thanks,

Gary

[RESOLVED] Problem with Standard DLL

$
0
0
Visual Basic doesn't normally create standard DLL library files, and I couldn't find any reference to such a utility in VBForums. So I searched and found an excellent AddIn from DanSoft Australia.
http://www.dansoftaustralia.net/developers/vb.htm
Once loaded as per the instructions, it adds a Standard DLL template to VB, as well as a menu item for creating the .def file. When compiled, the AddIn temporarily replaces the Linker to create the DLL.

And that's where I ran into this little problem. Everything works fine until I attempt to pass a string variable to the DLL. For example, this routine works just great when called as a simple function.
Code:

Private Declare Function BCryptOpenAlgorithmProvider Lib "bcrypt.dll" (ByRef hAlgorithm As Long, ByVal pszAlgId As Long, ByVal pszImplementation As Long, ByVal dwFlags As Long) As Long
Private Declare Function BCryptCloseAlgorithmProvider Lib "bcrypt.dll" (ByVal hAlgorithm As Long, ByVal dwFlags As Long) As Long

Function DLLMain(ByVal A As Long, ByVal B As Long, ByVal c As Long) As Long
    DLLMain = 1
End Function

Sub Main()
    'This is a dummy, so the IDE doesn't complain
    'there is no Sub Main.
End Sub

Function GetECC(ByVal sAlg As String) As Boolean
    lRet = BCryptOpenAlgorithmProvider(hProv, StrPtr(sAlg), StrPtr("Microsoft Primitive Provider"), 0)
    If lRet <> 0 Then
        GetECC = False
        GoTo ReleaseHandles
    End If
    GetECC = True
ReleaseHandles:
    If (hProv) Then BCryptCloseAlgorithmProvider hProv, 0
End Function

But when I run it as a standard DLL it fails with Error &HC0000225. If I change the function to:
Code:

Function GetECC(ByVal sAlg As String) As Boolean
    lRet = BCryptOpenAlgorithmProvider(hProv, StrPtr("ECDH_P256"), StrPtr("Microsoft Primitive Provider"), 0)
    If lRet <> 0 Then
        GetECC = False
        GoTo ReleaseHandles
    End If
    GetECC = True
ReleaseHandles:
    If (hProv) Then BCryptCloseAlgorithmProvider hProv, 0
End Function

it works just fine. Is there something different about the way DLLs handle string information. In this particular case the variable is required to be a double wide (ie. Unicode) string.

J.A. Coutts

[RESOLVED] Send Email via smtp.gmail.com Problem

$
0
0
I have no problem using these codes in yahoomail.
But when I've try to tweak a little bit, it doesn't work with GMail.

Code:


    Dim cdoMsg As New CDO.Message

    With cdoMsg
        With .Configuration.Fields
            .Item(cdoSendUsingMethod).Value = cdoSendUsingPort
            .Item(cdoSMTPUseSSL).Value = True
            .Item(cdoSMTPServerPort).Value = 465
            .Item(cdoSMTPServer).Value = "smtp.gmail.com"
            .Item(cdoSendUserName).Value = "xxxx@gmail.com"
            .Item(cdoSendPassword).Value = "xxxxxx"
            .Item(cdoSMTPAuthenticate).Value = cdoBasic
            .Update
        End With
        .From = "xxxx@gmail.com"
        .To = "xxxx@yahoo.com"
        .Subject = "Sample Message"
        .TextBody = "Message from gmail"
        .AddAttachment App.Path & "\ph3.jpg"
       
        .Send
    End With
   
    If Err.Number <> 0 Then
        MsgBox "CDO error " & Hex$(Err.Number) & vbNewLine & Err.Description, _
              vbOKOnly Or vbExclamation, _
              Caption
    Else
        MsgBox "Mail sent!", vbOKOnly, Caption
    End If


Any help? Transport Error

Using Debug.Print

$
0
0
Is there a way to clear the debug window. I'm debugging a function and I would like the debug window to be cleared each time it enters the function otherwise too much stuff is printed

Creating tables in MS Access

$
0
0
I am having a problem creating more than 8 fields in Access database when creating using ADO control in VB6.0. I get an error of file being too large. Any help is appreciated. The code is as follows:

Dim FileName As String, strConn As String
Dim adoCat As ADOX.Catalog, adoTable As ADOX.Table
Dim tblCollection As Collection
Dim Script As Object

' 'display Check for DB
' lblPB.Caption = "Checking for database..."
'check and/or build DB
Set Script = CreateObject("Scripting.filesystemobject")
If Script.FolderExists("C:\Business Pro") Then
'folder is in place...move on
If Dir("C:\Business Pro\BusinessPro.mdb") = "" Then
'dir not in place...build
lblPB.Caption = "No database found. Creating database..."
FileName = "C:\Business Pro\BusinessPro.mdb"
'create instance of ADOX-object
Set adoCat = New ADOX.Catalog
'creat instance of Collection-object
Set tblCollection = New Collection
Set adoTable = New ADOX.Table
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & FileName & ";"
'create the db
adoCat.Create (strConn)
'name table
tblCollection.Add "Customer_Contacts"
With adoTable
.Name = "Customer_Contacts" 'name the table
.Columns.Append "CustID", adInteger 'create a field in primary key
.ParentCatalog = adoCat 'set Parent catalog
.Columns("CustID").Properties("AutoIncrement").Value = True
.Keys.Append "PrimaryKey", adKeyPrimary, "CustID" 'append primary key
'add rest of fields
.Columns.Append "FirstName", adWChar
.Columns.Append "LastName", adWChar
.Columns.Append "Address", adWChar
.Columns.Append "City", adWChar
.Columns.Append "State", adWChar
.Columns.Append "Zip", adLongVarWChar, 5
.Columns.Append "PhoneNumber", adLongVarWChar, 10
End With
'add table to mdb
adoCat.Tables.Append adoTable

'create 2nd table
Set adoTable = New ADOX.Table
'name table
tblCollection.Add "Labor_Rates"
With adoTable
.Name = "Labor_Rates" 'name the table
.Columns.Append "ID", adInteger 'create a field in primary key
.ParentCatalog = adoCat 'set Parent catalog
.Columns("ID").Properties("AutoIncrement").Value = True
.Keys.Append "PrimaryKey", adKeyPrimary, "ID" 'append primary key
'add rest of fields
.Columns.Append "dateFiled", adDate
.Columns.Append "NumberCode", adWChar
.Columns.Append "Description", adWChar
.Columns.Append "LaborRate", adWChar
.Columns.Append "Frequency", adWChar

End With

'add table to mdb
adoCat.Tables.Append adoTable

'create 3rd table
Set adoTable = New ADOX.Table
'name table
tblCollection.Add "New_Contract"
With adoTable
.Name = "New_Contract" 'name the table
.Columns.Append "CustID", adInteger 'create a field in primary key
.ParentCatalog = adoCat 'set Parent catalog
.Columns("CustID").Properties("AutoIncrement").Value = True
.Keys.Append "PrimaryKey", adKeyPrimary, "CustID" 'append primary key
'add rest of fields
' .Columns.Append "dateFiled", adDate
.Columns.Append "ProjectCode", adWChar
.Columns.Append "Name", adWChar
.Columns.Append "Address", adWChar
.Columns.Append "City", adWChar
.Columns.Append "State", adWChar
.Columns.Append "Description", adWChar

'this is where the error comes in. If I comment the fields out, then the code works fine...
' .Columns.Append "LaborRate", adWChar
' .Columns.Append "DaysOnJob", adLongVarWChar
' .Columns.Append "Remarks", adWChar

End With
'add table to mdb
adoCat.Tables.Append adoTable

'release objects from memory
Set adoTable = Nothing
Set tblCollection = Nothing
Set adoCat = Nothing

'inform pb
lblPB.Caption = "Database created. Loading software..."
tmrLoad.Enabled = True
tmrLoad.Interval = 1000
Else:
lblPB.Caption = "Database exists. Loading software..."
tmrLoad.Enabled = True
tmrLoad.Interval = 1000

End If
Else
lblPB.Caption = "Making directory..."
'make directory
MkDir "C:\Business Pro"
'now create db
chkForDB
End If

Excel upgrade

$
0
0
I have an application that is written in VB6. In a number of places it either creates or updates an Excel spreadsheet. Everything was working just fine until IT upgraded the users from MS Office 2007 to MS Office 2013. Now it doesn't work. Is there a place where I can see what code needs to be changed to use MS Office 2013? I am assuming the logic that gets the data, etc. will not change, only the code that creates or updates the spreadsheet.

hiding stuff on window

$
0
0
Usually, if we dont want the user to see a component, it is set to .visible = false. Simple enough. Just out of curiosity, is it safe to set the component .Left = -500 (using a negative) so its way off to the left?

Seems to work. Just wondering if its safe to use a negative number in the .Left

[RESOLVED] Inter-Program Communication (all VB6).

$
0
0
Hi everyone,

I'm toying with an idea where I need to do inter-program communications. Both programs will be stand-alone EXEs.

Also, I'd truly rather not use disk I/O to get it done.

Also, I absolutely don't want to add a new OCX to get it done. Here's my bread-and-butter list:
comdlg32
mscomct2
mscomctl
richtx32
tabctl32

I've done this before with DDE, but it's been a while. I'm just wondering what ideas others have to get this done.

I am willing to use a timer, but it'd be nice if program1 could just get some event to fire in program2 when a message is sent.

Ahhh, and one more caveat. I don't want program1 to hang if program2 doesn't happen to be around.

Your ideas are greatly appreciated,
Elroy

Randomize Number (Long)?

$
0
0
If I wanted to randomize a number that's long (like, say, 1 to 20000), how could it be done?

Also, is there a way to randomize a number between certain numbers? Assuming that r is tha variable for the randomized number, that is.

Msg box default button

$
0
0
In VB6, I am using a message box to ask the user whether they really wish to delete. At the moment I have
Code:

Reply = MsgBox("Do you REALLY wish to delete", 4+16)
But the 'Yes' button is highlighted as the default and I would like to highlight the 'No' button as the default. I am aware of the vb syntax
Code:

vbYesNo + vbDefaultButton2
but that does not fit into the way I am doing it (with numbers to select parameters). Is there a way past this.

VB6 Application in LAN

$
0
0
Hello Friends,
I have developed the VB6 application with MS Access Database and Crystal report 8.5. The Software enables the user to add, edit, save records and more. It also having the total record count (Serial Number). It was perfectly working on single computer. But I need to connect it on LAN (Only two systems) and also have done it.

2 Computers. Both are Windows 7. Connected through standard LAN cable. It Successfully shows a connection.

I have installed my application on one computer(main). At another computer I just opened the program which was installed on main computer (With read, write, modify). It opens and works.

But my problem was
I have saved first record(Serial No 1) in main computer and ready to save next record(S.No :2)[Refreshed].
But in the second computer it showing to save first record(S.No :1). After I refreshed it showing to save S.No :2
Sometimes I forgot to refresh so it overwrites the second record in first record. This is my problem.

How to code to refresh the database automatically at runtime? or any other methods ?

Thanks,

Sort array in VB 6.0 using Arraylist

$
0
0
Hi all,

I have the same issue as mentioned.I used arraylist in vb 6.0.My arraylist contains "Layer 1" ,"Layer 12","Layer 3","Layer 10",Layer 2","All".But after sorting i got

Actual output: "Layer 1" ,"Layer 12","Layer 10",Layer 2,"Layer 3",All" [This i got after using arraylist.sort which is wrong]

Expected output: "Layer 1" ,"Layer 2","Layer 3","Layer 11",Layer 12","All".

Please help me ASAP Thank you


Thanks & Regards,
Sampath

VB6 Crystal Report and oralce

$
0
0
Aslam o alikum,

I create a report in Crystal report 9 with add command using Oracle 11g as Database with OLE DB (ADO) (Microsoft OLE DB provider for Oracle). It works fine in crystal report. I want to call this report from vb6 form. I m not using any server Machine , (VB6, ORACLE 11g, Crystal report 9 running on same PC(Machine).

the code i m using is as under :

this portion is defined in a Module

Code:

Public RptApp As New CRAXDRT.Application
Public Report As CRAXDRT.Report
Public crxTable As CRAXDRT.DatabaseTable
Public CPProperty As CRAXDRT.ConnectionProperty

This portion is in a VB6 form.

Code:

Set Report = RptApp.OpenReport(App.Path & "\Reports\ReportName.rpt")
  For Each crxTable In Report.Database.Tables
      crxTable.SetLogOnInfo "Host-Name", "ORCL", username, userpass
  Next

        Report.EnableParameterPrompting = False
        Report.DiscardSavedData

        Screen.MousePointer = vbHourglass
        frmReport.CRViewer91.ReportSource = Report
        frmReport.CRViewer91.ViewReport
        Screen.MousePointer = vbDefault

When i run the the program it give the error :
Logon Failed,
Details :ADO Error Code 080040e21
Source: Microsoft OLE DB service Components


Can any body let me know what changes should i do. Or what is correct code for.

Thanks in advance

About BitBlt function

$
0
0
Hi all,
I have a gif picture stored as resource data file. This means it returns a byte array but I need to use this picture in conjuction with BitBlt function that requires a hDC value. Is it possible any conversion at this step ? I would like to avoid creating a picturebox in the form only for this reason. Thanks.

Where can I find RichTextBox?

$
0
0
I havent touched VB for ages, I seem to have forgotten some of the basics...
I want a richTextBox on my form, it's not in the standard toolbox.

Which component 'set' is it in?

Thanks

[RESOLVED] Unicode versions of some VB6 string functions.

$
0
0
I have hit a brick wall in my current project. I can get a Unicode Filename/Meta-Tag or whatever and display it correctly.

However, the second I want to format it in any way Ucase$, Strconv(String,vbProperCase) or others there is an Ansi conversion and I am left with the dreaded ???????????????.

Is there a way round this?
Viewing all 21088 articles
Browse latest View live


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