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

[RESOLVED] First letter in capital letter

$
0
0
Hi
I found this function here that should make the first leter of a string in capital letter but I didn't find a way to use the function correctly.
Code:

Public Function SentenceCase(ByVal pstrText As String) As String
If Len(pstrText) > 0 Then Mid$(pstrText, 1, 1) = UCase$(Mid$(pstrText, 1, 1))
If Len(pstrText) > 1 Then Mid$(pstrText, 2) = LCase$(Mid$(pstrText, 2))
SentenceCase = pstrText
End Function

I failed to implement the function
Code:

Private Sub Text1_Change()
SentenceCase (Text1)
End Sub

Code:

Private Sub Text1_KeyPress(KeyAscii As Integer)
SentenceCase (Text1)
End Sub

thanks

[RESOLVED] Is there a way to lookup a string valu in notepad?

$
0
0
I'm creating a program file where my listview items are saved to notepad. Is there a way to lookup for identical items on my text document w/o the use of an API. And hoping that it will not add a newline that is identical?

runtime error 70 permission denied

$
0
0
Hello everyone, i have issue, when i try to use this code

Private Function isRunningExe(exeName As String) As Boolean
Dim strQuery As String
strQuery = "SELECT Name FROM Win32_Process WHERE Name= 'AvastUi.exe" & exeName & "'"

isRunningExe = GetObject("winmgmts:").ExecQuery(strQuery).Count

End Function
If isRunningExe("AvastUI.exe") Then
Sleep 30000
End If

E GET runtime error 79 permission denied, i was searching in google, but i I could not found solution,can somebody help me

[RESOLVED] VB6 Play multiple wave sounds simultaneously?

$
0
0
I have a virtual guitar program. When you click anywhere on the fretboard it plays the corresponding note from a library of wave files - one for each of the 72 notes possible on a 12 fret, 6 string guitar. The wave file is played using sndPlaySound Lib "WINMM.DLL" in my program.

This works fine for playing a single note, but if possible I would also like to play chords... which would require playing two or more of the note wave files simultaneously. Is this even possible in VB6? If not with WINMM.DLL then some other way?

I could use Audacity to manually create wave files combining the individual note files for each possible chord, but that's a minimum of 576 chord wave files to manually edit and create! Not to mention a lot of redundancy and hard drive space.

Any suggestions of a way to play multiple wave sounds simultaneously in VB6?

[Resoled] count occurrence of word in a rich text box

$
0
0
G'day folks.
I have RichTextBox loaded with the file I want to search and a textbox with the word I need to search for and count how many times it occurs in the RichTextBox.
I've tried various search methods to no avail.

The closest I have come to a simple function is this...
Code:

Dim nPos As Long
Dim nCount As Long
        nPos = -1
        Do
        nPos = InStr(nPos + 1, rtb1.text, Text1.text)
        If nPos Then
            nCount = nCount + 1
        End If
        Loop While nPos

however it returns an error "Invalid procedure call or argument" at this line...
Code:

nPos = InStr(nPos + 1, rtb1.text, Text1.text)
Any help in resolving this would be greatly appreciated. Thank you.

P.S.
I have a very similar search method in my app where the "nPos" is simply "Pos", it's not in a "Do / Loop" and it's dimmed as Variant instead of a Long. Although when I change the "nPos" in the above code to a Variant it still returns the same error. "Invalid procedure call or argument"

ImageControl Brightness propertie on Excel Worksheet

$
0
0
Hi,

i want get and change the Brightness propertie of picture on ImageControl on Excel Worksheet.
i am not want use setpixel or getpixel simple change of colors, but the properties of colors of picture.
or using color constants Declarations.

i know here not is forum of Microsoft Office but it is more graphics programming hardcore and VB programmers more advanced knowledge about this.

please patience.

thank you.

Trying to automate an Excel procedure

$
0
0
My knowledge of VB script is exceptional poor:

I am using software that allows the use of VB Script. The scenario:

I have identified a list of 461 items. The number of items will change every month. Each item has two dates I wish to compare and then count some of the results. I can export this list into excel and easily do the operation there however I am attempting to automate the process using VB Script.

The variables:
A: Expected delivery date
B: Closed date and time

In Excel I use DateDif(A,B,”d”) for each line. Then I use Count(the datedif results column,”>0”).

The objective is to know how many items have not been delivered before A (the expected delivery date).

I have tried various combinations of script functions to achieve a single value to be presented but without luck; typically mismatches. See below:

Function NumIndValue
If DateDif(A>B) Then
NumInvalue = 0
If DateDif(B>=A) Then
NumIndValue = Count(DateDif(B>A))
End If
End If
End Function

Any help would be greatly appreciated.

Any quick Scripting.Dictionary alternatives for Currency keys?

$
0
0
Hi,

I need a class that can quickly store/access to key-value para (type = full Currency, all 8 bytes, like 123456789012345.6789@ and number of elements ~ 200.000 to 1 mln).

Let's start with a small one.

Please, look here on my speed difference test for just 50.000 elements beetween:
1234567
and
12345678
numbers as a start point for a key:
Code:


Option Explicit

Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Any) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Any) As Long

Private Sub Form_Load()

    RunProc 1234567
    RunProc 12345678

    Unload Me
End Sub

Sub RunProc(begin As Long)
    Debug.Print "Begin: " & begin
    PrintTime bResetTimer:=True

    Dim oDict As Object, c As Long
    Set oDict = CreateObject("Scripting.dictionary")

    For c = 1 To 50000
        oDict.Add begin + c, c
    Next

    Set oDict = Nothing
    PrintTime
End Sub

Sub PrintTime(Optional bResetTimer As Boolean)
    Static freq As Currency, tim1 As Currency

    If bResetTimer Then
        QueryPerformanceFrequency freq
        QueryPerformanceCounter tim1
    Else
        Dim tim2 As Currency
        QueryPerformanceCounter tim2
        Debug.Print Format((tim2 - tim1) / freq, "##0.000s")
    End If
End Sub

Diiference is a huge:
Quote:

Begin: 1234567
0,111s
Begin: 12345678
18,083s
So, Scripting.dictionary is absolutely not suitable for my case.

Note, that in VB.NET Scripting.dictionary has no such speed problem. Test on 0.5 mln elements on ULong keys took less than 1 sec.:
Code:


Module Module1

    Dim oDict As New Dictionary(Of ULong, ULong)
    Dim file As System.IO.StreamWriter

    Sub Main()
        Dim c As ULong, begin As ULong, tmp As ULong, shift As Integer

        begin = 1234567890123456789

        shift = Int(Rnd() * 1000)

        ' 0,5 mln. iterations
        For c = 1 To 500000 * shift Step shift
            oDict.Add(begin + c, c)
        Next

        file = My.Computer.FileSystem.OpenTextFileWriter("c:\temp\currency.txt", True)

        For c = 1 To 500000 * shift Step shift
            tmp = oDict(begin + c)
            file.WriteLine(tmp)
        Next
        file.Close()

        'test, just in case
        oDict.Add(123, 111)
        Console.WriteLine(oDict(123))

    End Sub
End Module


Are there ready for use solutions?
Thanks.

Expected Expression error? What's the problem?

$
0
0
When ever I try to compile I get an expected expression error, im new to vb and just need to compile this to use with C# as an encryption .dll.
Code:

Option Explicit
 
Public LastError As Long
Public LastErrorDesc As String
 
Public Enum TWOFISHKEYLENGTH
    TWOFISH_256 = 256
    TWOFISH_196 = 196
    TWOFISH_128 = 128
    TWOFISH_64 = 64
End Enum
 
Private Type ENCRYPTCLASS
    Name As String
    Object As Object
    Homepage As String
End Type
 
Private Const BENCHMARKSIZE = 1000000
Private Const ROUNDS = 16
Private Const BLOCK_SIZE = 16
Private Const MAX_ROUNDS = 16
Private Const INPUT_WHITEN = 0
Private Const OUTPUT_WHITEN = INPUT_WHITEN + BLOCK_SIZE / 4
Private Const ROUND_SUBKEYS = OUTPUT_WHITEN + BLOCK_SIZE / 4
Private Const GF256_FDBK_2 = &H169 / 2
Private Const GF256_FDBK_4 = &H169 / 4

The &H169 / 2 is causing the error, but I don't know what to do. Any suggestions>

Image PIxel Color Coordinates Correct Orderind XY To Plot Shape ?

$
0
0
Hi,

i want algorithm VB or VBA to get all XY Coordinates of picture pixels colors in correct order to trace the contours edges to plot a vector shape of original picture.

i am able to get the coords of neighbors pixels but not in correct order.

please the code, thank you.

Does anyone continue to develop vhGrid?

$
0
0
Many years ago, Steppenwolfe developed an excellent control vhGrid. Unfortunately, this control was discontinued 10 years ago. vhGrid is the most powerful vb open source control I've ever seen. I wonder if anyone else continues to develop new versions based on this excellent contro (vhGrid)?

The following is the link to the vhGrid source code:
http://www.planet-source-code.com/vb...67906&lngWId=1

Bit operations, two bits to one

$
0
0
Hi,

I have done some bitwise and bit shifting, and now i want to put 2 bits together.

I have
bit1 = 6 (msb00000110)
bit2 = 5 (101lsb)

I want to put them so i get:

Newbit = 56 (00000110101)


I guess it is a simply way of doing it, but i dont know how.

Thanks!:wave:

Automate or ByPass CSV File Download Dialog

$
0
0
Previously i used VB and Inet with a URL to download and process CSV data directly from a server. The vendor has now changed things -- assume because of the virus over last weekend.

This broke my program, but am able to download a CSV file but now receive a Dialog to open or save.

I would like to automate (save file) and/or bypass (open the file and handle the data) without having the dialog displayed or better yet ignoring the dialog.

I'm guessing I could either use either "SendKeys" or do FindWindow, and trigger associated controls on that Dialog using their handle BUT wonder if there is a better way to:

1) Bypass the Open/Save Dialog?
2) Know how this Dialog is triggered (displayed) --
is the dialog part of the HTML script that Firefox is processing or is Firefox calling a Open/Save File Dialog that is part of Windows when it sees a file is being downloaded, or ??

[RESOLVED] Any quick Scripting.Dictionary alternatives for Currency keys?

$
0
0
Hi,

I need a class that can quickly store/access to key-value para (type = full Currency, all 8 bytes, like 123456789012345.6789@ and number of elements ~ 200.000 to 1 mln).

Let's start with a small one.

Please, look here on my speed difference test for just 50.000 elements beetween:
1234567
and
12345678
numbers as a start point for a key:
Code:


Option Explicit

Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Any) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Any) As Long

Private Sub Form_Load()

    RunProc 1234567
    RunProc 12345678

    Unload Me
End Sub

Sub RunProc(begin As Long)
    Debug.Print "Begin: " & begin
    PrintTime bResetTimer:=True

    Dim oDict As Object, c As Long
    Set oDict = CreateObject("Scripting.dictionary")

    For c = 1 To 50000
        oDict.Add begin + c, c
    Next

    Set oDict = Nothing
    PrintTime
End Sub

Sub PrintTime(Optional bResetTimer As Boolean)
    Static freq As Currency, tim1 As Currency

    If bResetTimer Then
        QueryPerformanceFrequency freq
        QueryPerformanceCounter tim1
    Else
        Dim tim2 As Currency
        QueryPerformanceCounter tim2
        Debug.Print Format((tim2 - tim1) / freq, "##0.000s")
    End If
End Sub

Diiference is a huge:
Quote:

Begin: 1234567
0,111s
Begin: 12345678
18,083s
So, Scripting.dictionary is absolutely not suitable for my case.

Note, that in VB.NET Scripting.dictionary has no such speed problem. Test on 0.5 mln elements on ULong keys took less than 1 sec.:
Code:


Module Module1

    Dim oDict As New Dictionary(Of ULong, ULong)
    Dim file As System.IO.StreamWriter

    Sub Main()
        Dim c As ULong, begin As ULong, tmp As ULong, shift As Integer

        begin = 1234567890123456789

        shift = Int(Rnd() * 1000)

        ' 0,5 mln. iterations
        For c = 1 To 500000 * shift Step shift
            oDict.Add(begin + c, c)
        Next

        file = My.Computer.FileSystem.OpenTextFileWriter("c:\temp\currency.txt", True)

        For c = 1 To 500000 * shift Step shift
            tmp = oDict(begin + c)
            file.WriteLine(tmp)
        Next
        file.Close()

        'test, just in case
        oDict.Add(123, 111)
        Console.WriteLine(oDict(123))

    End Sub
End Module


Are there ready for use solutions?
Thanks.

Creating an ASCII file from Trimble Terrasync files

$
0
0
I purchased a Trimble Geo XH 2005 with Terrasync years ago. I have file extensions but they are not showing me the Northing, Easting, Elevation and Description text files that I need to use in Autocad. I only get the file extensions: .car, .dd, .gic, .gip, gis, giw, gix, obs, and obx, and ssf. I just see a bunch of code such as:

3 P Generic wâRCreated by datalogger 4 ` -001Point_generic ! f 4 ` -007Comment A -001 f 6 p Ê v ø ^ -001 @ -007 d 4 ` -002Line_generic " f 4 ` -008Comment B -002 f 6 p Ê v ø ^ -002 @ -008 d 4 ` -003Area_generic $ f 4 ` -009Comment D -003 f 6 p Ê v ø ^ -003 @ -009 d 5

Is there a way to code VB 6.0 to change one or all of these files to a ascii or text .txt file?

Regular expressions: VBScript.Regexp alternatives

Regular expressions: VBScript.Regexp alternatives

$
0
0
Hi,
sometimes vbscript.dll is unregistered on some machines.
For reliability, I used to use modTrickUnregCOM together with it like:
Code:

CLSIDFromString StrPtr("{3F4DACA4-160D-11D2-A8E9-00104B365C9F}"), iidRegExp
Set objCOM = UnregCOM.CreateObjectEx(EnvironW("%SystemRoot%") & "\s y s t e m32\vbscript.dll", iidRegExp) 'remove spaces!
If Not (objCOM Is Nothing) Then Set NewRegExpClass = objCOM

But, sometimes dll is even damaged. So, for worst cases, I need a replacement like own class or a little dll. I looked closely at PCRE.
It has cdecl style CC.

However, I unable to prepare code correctly.
Please, look where I failed (or maybe you have another alternatives). Thank you.

Here is required dlls (or compile sources from off. site (I currently expecting problem with compiling the latest v1 (8.40) version myself)).
The code attached display:
Quote:

PCRE Version = 7.0 18-Dec-2006
reCompiled = 0x6A6EC0
argument is not a compiled regular expression
Error while optimizing (study) regex!
Too many strings were found. Must increase subStrVec array
PCRE_api\pcre_exmaple.c file contains C-examples (see also pcre_API_Reference.txt, section "STUDYING A PATTERN" and further).
Attached Files

OpenConnection Fails on Command Line Works in IDE

$
0
0
Greetings,

I have a vb 6.0 "desktop" application that has multiple components. One of those components is a dll that gets called to perform various database functions. These functions include making the database connection, submitting SQL queries and returning results. It all works fine when it's run in the VB 6.0 IDE. However, when I try to run it on the command prompt, it errors out. The error occurs at this line:

Set Current_Database = Current_Workspace.OpenConnection("DOCUGEN Database", dbDriverNoPrompt, False, Connect_String)

where we set the database connection using the OpenConnection method of the Workspace. The Current_Database is a DAO connection object. This error is not captured by the program, the On Error statement seems to have no effect, the program just crashes. I am able to get this information from the Application Verifier logs:

<avrf:logfile xmlns:avrf="Application Verifier">
<avrf:logSession Version="2" PID="4432" TimeStarted="2017-05-19 : 08:14:07">
<avrf:logEntry Severity="Error" StopCode="0xE100" LayerName="Networking" Time="2017-05-19 : 08:14:08">
<avrf:message>Illegal networking API called from DllMain</avrf:message>
<avrf:parameter1>74a11d10 - Networking function being called from DllMain</avrf:parameter1>
<avrf:parameter2>8348fda - Name of Dll making invalid call if not NULL</avrf:parameter2>
<avrf:parameter3>0 - Not used</avrf:parameter3>
<avrf:parameter4>0 - Not used</avrf:parameter4>-<avrf:stackTrace>
<avrf:trace>vfnet!+74a13607 ( @ 0)</avrf:trace>
<avrf:trace>OraOCIICUS11!ztcsl+39dd ( @ 0)</avrf:trace>
<avrf:trace>OraOCIICUS11!+c991041 ( @ 0)</avrf:trace>
<avrf:trace>OraOCIICUS11!ociepacm+3cb ( @ 0)</avrf:trace>
<avrf:trace>OraOCIICUS11!ociepacm+484 ( @ 0)</avrf:trace>
<avrf:trace>vrfcore!VerifierTlsSetValue+431 ( @ 0)</avrf:trace>
<avrf:trace>vfbasics!VerifierDisableFaultInjectionExclusionRange+c55 ( @ 0)</avrf:trace>
<avrf:trace>ntdll!RtlQueryEnvironmentVariable+241 ( @ 0)</avrf:trace>
<avrf:trace>ntdll!LdrResSearchResource+b4d ( @ 0)</avrf:trace>
<avrf:trace>ntdll!LdrResSearchResource+a10 ( @ 0)</avrf:trace>
<avrf:trace>ntdll!LdrLoadDll+7b ( @ 0)</avrf:trace>
<avrf:trace>vfbasics!VerifierDisableFaultInjectionExclusionRange+1087 ( @ 0)</avrf:trace>
<avrf:trace>KERNELBASE!LoadLibraryExW+1f1 ( @ 0)</avrf:trace>
<avrf:trace>KERNELBASE!LoadLibraryExA+26 ( @ 0)</avrf:trace>
<avrf:trace>KERNEL32!LoadLibraryA+31 ( @ 0)</avrf:trace>
<avrf:trace>OCI!koptdumptds_check+617 ( @ 0)</avrf:trace>
<avrf:trace>OCI!lpminit+8 ( @ 0)</avrf:trace>
<avrf:trace>SQORA32!SQLTablesW+36a ( @ 0)</avrf:trace>
<avrf:trace>SQORA32!SQLTablesW+766 ( @ 0)</avrf:trace>
<avrf:trace>verifier!+728fc66d ( @ 0)</avrf:trace>
<avrf:trace>vrfcore!VerifierTlsSetValue+431 ( @ 0)</avrf:trace>
<avrf:trace>vfbasics!VerifierDisableFaultInjectionExclusionRange+c55 ( @ 0)</avrf:trace>
<avrf:trace>ntdll!RtlQueryEnvironmentVariable+241 ( @ 0)</avrf:trace>
<avrf:trace>ntdll!LdrResSearchResource+b4d ( @ 0)</avrf:trace>
<avrf:trace>ntdll!LdrResSearchResource+a10 ( @ 0)</avrf:trace>
<avrf:trace>ntdll!LdrLoadDll+7b ( @ 0)</avrf:trace>
<avrf:trace>vfbasics!VerifierDisableFaultInjectionExclusionRange+1087 ( @ 0)</avrf:trace>
<avrf:trace>KERNELBASE!LoadLibraryExW+1f1 ( @ 0)</avrf:trace>
<avrf:trace>ODBC32!VFreeErrors+2ff5 ( @ 0)</avrf:trace>
<avrf:trace>ODBC32!SQLDisconnect+593 ( @ 0)</avrf:trace>
<avrf:trace>ODBC32!SQLDisconnect+6f4 ( @ 0)</avrf:trace>
<avrf:trace>MSRDO20!DllGetClassObject+1933 ( @ 0)</avrf:trace>
<avrf:trace>MSRDO20!DllGetClassObject+1492 ( @ 0)</avrf:trace>
<avrf:trace>MSRDO20!DllGetClassObject+e7f ( @ 0)</avrf:trace>
<avrf:trace>MSRDO20!DllGetClassObject+d29 ( @ 0)</avrf:trace>
<avrf:trace>MSRDO20!DllGetClassObject+c72 ( @ 0)</avrf:trace>
</avrf:stackTrace>
</avrf:logEntry>
</avrf:logSession>
</avrf:logfile>

Does anyone have any idea what is going on and how this can be resolved? Moving to different technologies is not an option because there is too much code involved.

Many thanks.

Align Justify in DataReport Label

$
0
0
Friends,

1. I had used a Label in Data Report. I need to use a letter paragraph in the said label. But i was unable to Align Justify.

There is 3 alignment property is there;

0-rptJustifyLeft, 1-rptJustifyRight, 2-rptJustifyCenter

Please help me to sort out the issue.

2. Need to use a continuous number in a label in all pages. Please help me that too.

Guna

add + 1 in dictionary(FSO object)

$
0
0
i loop a text file with the simple freefile.
during the loop i get from each line with mid statement a part of string and assign to MyVar.
Myvar is string dimensioned.
In this case myVar is the name of a City
now i need to assign on a City +1 value in a dictinary in loop...

example for pseudo code:

City="roma"
Not exists, in Dictionay record, for first occurrence Roma+1
next line from txt
City="Roma"
Roma alredy exist with 1 value
Roma,1+1
ecc...
In effect i need to count each occurence based the City to the end of txt

Then, now i need to loop each items in dictionary....

sory for my bad english
Viewing all 21106 articles
Browse latest View live


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