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

[RESOLVED] LINK : fatal error LNK1158: cannot run "cvtres.exe"

$
0
0
Received the following LINK : fatal error LNK1158: cannot run "cvtres.exe".

Working on a VB6 project and suddenly am getting this when trying to create an installation package, or File>Make. Not sure what happened and doesn't seem to be anything new that was done on the Windows XP VM I'm running the development software on. A search for cvtres.exe resulted in finding 2 copies, both located in then Microsoft.NET\Framework directories under different versions.

BrowseForFolder and Editbox and events

$
0
0
Hi,
I've searched these forums but I couldn't find a topic which already discusses this.

With the BrowseForFolder you can enable the Editbox, but it seems there is no direct callback (using the same callback as the BFFM_INITIALIZED and BFFM_SELCHANGED are handled) when a user enters text.
If I have the OK button disabled (through some check during callback BFFM_SELCHANGED) and a user types something, the button is automatically enabled again (until the user deleted all text in the editbox) without me getting any events not until the user pushes <enter> or tries the <OK> button, then if it's an nonexisting folder it will trigger the BFFM_VALIDATEFAILEDA event, but if the folder exists it closes the window (but I want/have the OK button disabled (during BFFM_SELCHANGED) because there isn't a specific file in the folder).
Is there a flag to get a BFFM_???? event during typing or is the only way to do it by setting up a callback myself by hooking into the editbox window?

I do see a BFFM_SELCHANGED when the folder exists and the user has pushed enter or the OK button, but I don't seem to be able to block the dialog from closing during that event, which for BFFM_VALIDATEFAILEDA is as easy as just letting the callback return 1. So another option would be to block the dialog from closing during BFFM_SELCHANGED, but how?

How do you consume a webservice in VB6?

$
0
0
I have a VB 6 program that needs to send an HTTP request structured using XML tags which in turn will send back a response in XML.

It looks like a simple enough problem but I seem to be going around in circles for days on this.

Documentation is scant but appears to be straightforward ie.

Quote:


Send to http://services/WebService/UserWebservice.svc

<Request type='USERACCESS'>
<Parameters>
<Parameter name='USERID'>A12345</Parameter>
</Parameters>
</Request>

A Response would be in the form

<Response type="USERACCESS">
<Values>
<Value name="RESULT">TRUE</Value>
</Values>
</Response>

Any help on how to approach this in Visual Basic 6 would be hugely appreciated.

Thanks!

Is there a LongLong type hidden in VB6?

$
0
0
Is there a LongLong type hidden in VB6?

Here's why I ask the question. I'm playing around with Decimals (in Variants), and I stumbled across something strange.

Okay, for those familiar with Decimals, we know that they've got 12 bytes of unsigned mantissa. (The sign bit is stored separately, as well as the exponent.) Therefore, if we treat these Decimals as integers, we should be able to get values (in hex) from 0 to FFFFFFFFFFFFFFFFFFFFFFFF (either positive or negative).

Now, here's the curiosity. If we run the following code, we get -1, and not 18446744073709551615 (2^64-1).

Code:


Option Explicit

Private Sub Form_Load()
    MsgBox CDec("&Hffffffffffffffff")
    '              1234567890123456
End Sub

Now just where did VB6 come up with the idea to interpret "&Hffffffffffffffff" as -1? That only makes sense if you interpret that string as representing a LongLong (and not a 12 byte integer).

Another curiousity is that the following results in an overflow:

Code:


Option Explicit

Private Sub Form_Load()
    MsgBox CDec("&H10000000000000000")
    '              12345678901234567
End Sub

If VB6 truly recognized that it was allowing this hex string into a Decimal, it should allow up to "&Hffffffffffffffffffffffff" (12 bytes), and maybe even a bit in the next byte to indicate the sign. But that all results in an overflow.

Therefore, it appears that hex strings are correctly handled as LongLong types when stuffing them into a Decimal type.

Anyone have any further insights on this?

Elroy

How does the IDE remember project settings?

$
0
0
When opening a VB6 project the IDE displays windows that were open during the last session. Sometimes. Sometimes not. If I bring a file window to the foreground, how can I ensure that the same screen layout will be restored when I next open the project? The "Save Project" menu item doesn't do it.

undeclared variables in VB6

$
0
0
How does VB6 decide what data type to apply to undeclared variables?

Example -

If a DLL function is declared as

Code:

Declare Function cbDBitIn Lib "cbw32.dll" (ByVal BoardNum&, ByVal PortType&, ByVal BitNum&, BitValue%) As Long
and a call to this function is

Code:

ULStat% = cbDBitIn(0, FIFTHPORTB, (x + CHIPOffsetU3), ReturnBit)
and the variables ULStat and ReturnBit are not declared anywhere, does the compiler use the data types of the function declaration to determine what the variables are?

BTW it's not my code, I always use Option Explicit.

TIA

Delete items from listview and database

$
0
0
Hello experts
I want to delete items from listview and access database but I couldn't do that.
Code:

DB.Execute "Delete from tbl_soc where PID = " & Lvw1.ListItems(I).SubItems(4) & "' and sid  = " & Lvw1.ListItems(I).SubItems(5) & "' and date_st = '" & Lvw1.ListItems(I)
I'm getting syntax error
thanks for help

Arrays of radius of circles

$
0
0
Good day everyone. I am having trouble with a question given by my lecturer. Here it goes. Im not so sure how the question even runs.
There is 3 labels and 3 textboxes next to it. Label 1- Enter radius from, Label 2 - Enter radius to, Label 3- Increment value. Then listview with 2 columns divided- radius of circle with increment value 2 eg:1,3,5,7,9 and next column- area of circle. He says arrays r required. I have no idea how to continue. Pls guide me step by step . I want to master this well and properly. What i don't understand is that he says the increment needed is 2 but he has given textbox for increment. What is the point? Here is my code. Hopefully u can visualize. Another thing, how to insert images? i try clicking on the insert image but everytime nothing comes out.

Code:

Public Class Form1

 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        ListView1.GridLines = True
        ListView1.Columns.Add("Radius", 100)
        ListView1.Columns.Add("Area of a circle", 100)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(2) As String
        Dim itm As ListViewItem
        Dim a As Integer
        a = Val(TextBox1.Text)
        Dim b As Integer
        b = Val(TextBox2.Text)
        Dim c As Integer
        c = Val(TextBox3.Text)


        For x = 1 To 15 Step 2
            arr(0) = x
            arr(1) =

        Next x

    End Sub
End Class


File bigger than 2GB to Array using FileMapping API

$
0
0
I want to open a file and convert it to a array.
I wanna use File Mapping APIs because it's more efficient.

when file is smaller than 2GB, this function works fine
but how to handle bigger ones

is that the 3 red lines than should be changed?
Code:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const OPEN_EXISTING = 3
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Const FILE_ATTRIBUTE_READONLY = &H1
Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_SYSTEM = &H4

Private Declare Function CreateFileMapping Lib "kernel32" Alias "CreateFileMappingA" (ByVal hFile As Long, ByVal lpFileMappigAttributes As Long, ByVal flProtect As Long, ByVal dwMaximumSizeHigh As Long, ByVal dwMaximumSizeLow As Long, ByVal lpName As String) As Long
Private Declare Function MapViewOfFile Lib "kernel32" (ByVal hFileMappingObject As Long, ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Private Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As Any) As Long
Private Const PAGE_READWRITE = &H4
Private Const FILE_MAP_READ = &H4

Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long
Private Type SAFEARRAYBOUND
    cElements As Long
    lLbound As Long
End Type
Private Type SAFEARRAY1D
    cDims As Integer
    fFeatures As Integer
    cbElements As Long
    clocks As Long
    pvData As Long
    rgsabound(0) As SAFEARRAYBOUND
End Type

Function FileToArrayMapping(ByVal strFileName$) As Byte()
    Dim hFile&, hFileMap&
    Dim nFileSize&, lpszFileText&, FileArr() As Byte
    Dim ppSA&, pSA&
    Dim tagNewSA As SAFEARRAY1D, tagOldSA As SAFEARRAY1D
    hFile = CreateFile(strFileName, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL Or FILE_ATTRIBUTE_ARCHIVE Or FILE_ATTRIBUTE_READONLY Or FILE_ATTRIBUTE_HIDDEN Or FILE_ATTRIBUTE_SYSTEM, 0)
    If hFile <> 0 Then
        nFileSize = GetFileSize(hFile, ByVal 0&)
       
        hFileMap = CreateFileMapping(hFile, 0, PAGE_READWRITE, 0, 0, vbNullString)
        lpszFileText = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0)
         
        ReDim FileArr(0)
        ppSA = VarPtrArray(FileArr)
        CopyMemory pSA, ByVal ppSA, 4
        CopyMemory tagOldSA, ByVal pSA, Len(tagOldSA)
        CopyMemory tagNewSA, tagOldSA, Len(tagNewSA)
        tagNewSA.rgsabound(0).cElements = nFileSize
        tagNewSA.pvData = lpszFileText
        CopyMemory ByVal pSA, tagNewSA, Len(tagNewSA)
        FileToArrayMapping = FileArr
        CopyMemory ByVal pSA, tagOldSA, Len(tagOldSA)
        Erase FileArr
        UnmapViewOfFile lpszFileText
        CloseHandle hFileMap
    End If
    CloseHandle hFile
End Function

VB6 Variant VarType Question

$
0
0
Elroy's recent LongLong thread got me to wondering about something:

Suppose you had a procedure that had a ByRef Variant as a parameter . . .

Quote:

MySub(Vnt as Variant)

If VarType(Var) = vbSingle Then

' change vartype in variant to a Long (VT_14) - a cheap form of casting

' now do bit operation or something else on Vnt as if it were a Long
End Sub
Would this work? Would it work if the parameter was ByVal?

I was thinking of experimenting, but I thought maybe some else has already tried.

Thank you in advance.
rdee

i = any number?

$
0
0
this question should be easy. just cant think of a syntax for it.......

I'd like 'i' to = any number

[RESOLVED] Encryption / Security (something fairly simple)

$
0
0
I've never messed with encryption/security much, always letting the network administrators, the domain passwords, and the SmartCards take care of that.

However, I'm now being asked to consider a bit of it. Let me outline the situation.

We're setting up an Oracle SQL Server over a WAN. It will be fed data via VB6 front-ends from several sites. Obviously, this VB6 front-end will need read/write and record create/delete access to the Server's tables. There are several other "levels" of passwords being proposed for the SQL server, but I'm proposing that the VB6 front-end have a unique SQL server password that isn't used by anyone else.

However, my front-end source code is open source (and used by other institutions that aren't part of this specific SQL server project). Therefore, I've got to find a way to protect my special SQL server read/write password.

My idea was to have a small text (or even binary) file that gets distributed specifically to people that are part of this SQL server project. And there's the question.

How do I write some encrypted string into some text (or binary) file that is fairly difficult to read. I understand that someone could get the file and the source code and figure it out. But that's unlikely in that the distribution of the file itself will be very protected. Also, maybe I'll write a small ActiveX.dll that isn't open source that's specifically for reading this file.

The primary objective is to prevent snooping eyes (within an approved institution) from reading this file with notepad, or even a hex editor.

Thanks,
Elroy

[RESOLVED] Delete items from listview and database

$
0
0
Hello experts
I want to delete items from listview and access database but I couldn't do that.
Code:

DB.Execute "Delete from tbl_soc where PID = " & Lvw1.ListItems(I).SubItems(4) & "' and sid  = " & Lvw1.ListItems(I).SubItems(5) & "' and date_st = '" & Lvw1.ListItems(I)
I'm getting syntax error
thanks for help

[RESOLVED] Arrays of radius of circles

$
0
0
Good day everyone. I am having trouble with a question given by my lecturer. Here it goes. Im not so sure how the question even runs.
There is 3 labels and 3 textboxes next to it. Label 1- Enter radius from, Label 2 - Enter radius to, Label 3- Increment value. Then listview with 2 columns divided- radius of circle with increment value 2 eg:1,3,5,7,9 and next column- area of circle. He says arrays r required. I have no idea how to continue. Pls guide me step by step . I want to master this well and properly. What i don't understand is that he says the increment needed is 2 but he has given textbox for increment. What is the point? Here is my code. Hopefully u can visualize. Another thing, how to insert images? i try clicking on the insert image but everytime nothing comes out.

Code:

Public Class Form1

 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        ListView1.GridLines = True
        ListView1.Columns.Add("Radius", 100)
        ListView1.Columns.Add("Area of a circle", 100)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(2) As String
        Dim itm As ListViewItem
        Dim a As Integer
        a = Val(TextBox1.Text)
        Dim b As Integer
        b = Val(TextBox2.Text)
        Dim c As Integer
        c = Val(TextBox3.Text)


        For x = 1 To 15 Step 2
            arr(0) = x
            arr(1) =

        Next x

    End Sub
End Class

[RESOLVED] i = any number?

$
0
0
this question should be easy. just cant think of a syntax for it.......

I'd like 'i' to = any number

populate a textbox from a listview

$
0
0
Hi all
I need to populate a textbox from a listview and I need to add date.

I have this code to copy items for the first time.

Code:

If Text1.Text = "" Then
Text1.Text = Date & vbNewLine & Listview1.SelectedItem.Text
End If

The output is this:

04/12/2016
AAAAAAAA
BBBBBBBB
CCCCCCCC

This data is saved in database

The next time when retreiving this data from database, I need to add today's date seperating the old items with the new ones.

The final output should be:

04/12/2016
AAAAAAAA
BBBBBBBB
CCCCCCCC

05/12/2016
DDDDD
EEEEE
FFFFFF

thank you for any helpful idea

C to VB

$
0
0
So do you head to a C forum or a VB forum when you have a question about converting a line of C code to VB?

I can remember a while back reading about a contest to see who could write the most complicate function in C using only one line of code and while the results were impossible to read, they were amazing.

I have a line of code that’s not all that complicated, but it doesn’t take much to confuse me!


Code:

      x | = (long) (( (Value & (((long) 1) << Index )) ? 1:0)) << ( bits-1-Index );

The best I can guess is that the ‘long’ keywords might be some sort of type casting, and the question mark a logical conditional, selecting either a 1 or 0, and the twin less than symbols shift bits. But that’s it, trying to put it all together and I’m lost. This is what I have come up with, short of adding in the function for shifting bits to replace the <<.


Code:

      x = x or IIf( ((Value and 1) << Index ), 1, 0) << (bits - 1- Index )

Unfortunately I don't have anyway to test the C code right now as I lost a hard disk and I am still rebuilding. I'm getting odd values from the function but don't really have a good way to compare numbers till I get the rest of my system rebuilt, hunting for license keys is maddening.

So any ideas or thoughts on whether the VB code matches the C code?

Thanks.

Using vb6 to run cammand line stuff

$
0
0
I want to get the duration of .flac audio files and have found that metaflac.exe which is part of the flac package
will give you data (from DOS command line) which can be converted thus:

number_samples=(metaflac --show-total-samples "file")
sample_rate=(metaflac --show-sample-rate "file")
seconds=(number_samples / sample_rate)

Can I use VB6 anyhow to get values number_samples and sample_rate ?

Thanks for any info.

check un check checkbox in listview

$
0
0
I need to assign to the same label (on click event) a check and uncheck for each checkbox in a listview... possible?

Tks.

example: first clIck on label1 check all checkbox, i reclik on the same label1, uncheck all checkbox

[RESOLVED] populate a textbox from a listview

$
0
0
Hi all
I need to populate a textbox from a listview and I need to add date.

I have this code to copy items for the first time.

Code:

If Text1.Text = "" Then
Text1.Text = Date & vbNewLine & Listview1.SelectedItem.Text
End If

The output is this:

04/12/2016
AAAAAAAA
BBBBBBBB
CCCCCCCC

This data is saved in database

The next time when retreiving this data from database, I need to add today's date seperating the old items with the new ones.

The final output should be:

04/12/2016
AAAAAAAA
BBBBBBBB
CCCCCCCC

05/12/2016
DDDDD
EEEEE
FFFFFF

thank you for any helpful idea
Viewing all 21196 articles
Browse latest View live


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