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

[RESOLVED] Storing Large Chunks of Data in VB6

$
0
0
Hi All,

I need a bit of brainstorming help. I've got a somewhat complex calculation I use Excel to do, and I want to pull it entirely into VB6. Pulling in the actual calculations is the easy part. However, the calculations also involve a rather large set of static data (think, a massive amount of Const data).

To give you an example of the size of this static data, it involves two Excel tabs. The larger tab has columns to IV and rows to 460. If you feel that you need to know more about the calculations, here's a poster that explains part of them. But understanding that has nothing to do with my question.

Yeah, I know about the Array() function, and I'll use that if I have to. The two downsides I immediately see to that are that it's only one dimension and also it returns a variant. Ideally, I'd like a two-dimensional array of Doubles.

I'm also looking for the easiest way to get this data into VB6 code. I don't want it in a file. I just want it hardcoded into a Class module.

Your Thoughts Are Appreciated,
Elroy

EDIT1: I still miss the old DATA and READ commands. I bet few remember those.

[RESOLVED] what is the code doing?

$
0
0
Code:


Private Function b() as Boolean
    If m_bWrapText Then
        Dim c As Long
        c= SendMessageA(txtEditor.hwnd, &HBA, 0, 0)  'EM_GETLINECOUNT
        b= SendMessageA(txtEditor.hwnd, &HBB, -1, 0) = SendMessageA(txtEditor.hwnd, &HBB, c - 1, 0) 'EM_LINEINDEX
    Else
        b=True
    End if
End Function

What is the function doing?

UserControl Center Property

$
0
0
I'm building a user control that has multiple Labels. I would like to create a yCenter and xCenter property that will locate the labels vertically and horizontally like this..
Code:

label1.yCenter = intVar
lablel1.xCenter = intVar

' Then other labels can be referenced to another label center like this...
Label2.yCenter = Label1.yCenter
Label2.xCenter = Label1.xCenter

I seem to get lost in the Property Let, Set & Get and the PropertyBag too. I've been reading through this link that's not UserControl specific or related but I think it's the foundation of what I'm trying to do.
https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx
Any help will be greatly appreciated.

Thanks,
Chris

[RESOLVED] Set a counter

$
0
0
Hello experts
I use the following code to create a counter in textfile.
The counter should rest to 0 when it reaches 100
the code seems to work but I'm not quite sure about its validity.
I need experts evaluation:
Code:

Private Sub Form_Load()
Dim p As Long
 Dim n As String
 leNombre = 0
 p = FreeFile
 On Error GoTo erreur
 Open App.Path & "\EMPLOYEE.txt" For Input As p
 Line Input #p, n
 Close (p)
 leNombre = Val(n) + 1
 GoTo suite
erreur:
 On Error Resume Next
 Close p
suite:
 p = FreeFile
 Open App.Path & "\EMPLOYEE.txt" For Output As p
 Print #p, leNombre
 Close (p)
 
 Open App.Path & "\EMPLOYEE.txt" For Input As p
 Line Input #p, n
 Close (p)
If leNombre = 100 Then
 GoTo suite2
 Close p
erreur2:
 On Error Resume Next
suite2:
 p = FreeFile
 Open App.Path & "\EMPLOYEE.txt" For Output As p
 Print #p, 0
 Close (p)
 End If
 Text1.Text = leNombre
End Sub

Is there a performance hit if I seperate a string expression in different lines?

$
0
0
Code:

var = "sometextverylong" & _
"sometextverylong" & _
"sometextverylong" & _
"sometextverylong"

Does the & operator here causes a string concatenation? I am simply trying to clarify the code a bit, If it has a performance hit, then what's the better approach?

saving data dilemma

$
0
0
I've been using Random Access file to save data to a file. The worst of it all is, if i do some changes to my program, and need to change some of the Save functions, like maybe i added a few text boxes to the program, and now the program has to save the new 'extra' data. Well, now my program cannot Open any of the old saved files. Mainly because of this; Dim ReadData(1 To 17) As Record. Where the new 'updated' program may have Dim ReadData(1 To 27) As Record.

Anyone who has used this will know what i'm talking about (or maybe im just doing it the hard way?).

Any advice??

Debug Add Watch on object property chage

$
0
0
Hello,

is there a way to add watch so that execution of the code stops (Break) when a property on an object (control on form) changes?

Keystroke for recording time from video

$
0
0
Hi to all! Sorry if I am not on right forum, but I don't know where else to ask this. I am a civil engineer and I don't have a lot of experinece with programming (just a little in Matlab). I have this problem: I want to play some video, and when I press some key, I want to record that time in excel or notepad. Also, I want to have several key options (4-5), and to record and sort times when I press some of these keys. Basicly, I need to start some kind of timer when I play video, and to record keystroke time wich is connected with that timer. I saw that it can be done with Visual Basic, but I don't know how. Is it too complicated to do this with VB, so I can learn that? Is there some example code for problem like this?

Thank you very much for any help!

Regards

[RESOLVED] Debug Add Watch on object property chage

$
0
0
Hello,

is there a way to add watch so that execution of the code stops (Break) when a property on an object (control on form) changes?

String Comparison on Keypress

$
0
0
Hello All,

I have created an application which has two password fields. What I want to compare the two fields and display the appropriate result. For instance, I have two textboxes, first one is the password and the second is re-enter the password. What I want is to compare the strings, when I key the password in the second textbox(i.e. keypress event not at last after entering all the characters), it should compare the entered character with the character in the first textbox, if it matches it should go to next character,else return error.

Can somebody explain me what to do and how to do this. Please explain me with some code too.

Thanks in advance and Have a nice day...

[RESOLVED] how to call this routine?

$
0
0
Hi all
Can anyone tell me how to call this sub?
Code:

Public Sub PrintListView(LV As ListView, Lines%)
* * Dim i%, LVWidth%, NewTab%, j%
* * Dim itmX As ListItem
* * Dim LineCount%
* *
* * LVWidth = 0
* * For i = 1 To LV.ColumnHeaders.Count
* * * * LVWidth = LVWidth + LV.ColumnHeaders(i).Width
* * Next
* * NewTab = 0
* * For i = 1 To LV.ColumnHeaders.Count
* * * * NewTab = NewTab + CInt(LV.ColumnHeaders(i).Width * Printer.ScaleWidth / LVWidth)
* * * * Printer.Print LV.ColumnHeaders(i).Text;
* * * * Printer.CurrentX = NewTab
* * Next
* * Printer.Print
* * If Lines < LV.ListItems.Count And Lines <> 0 Then
* * * * LineCount = Lines
* * Else
* * * * LineCount = LV.ListItems.Count
* * End If
* * For i = 1 To LineCount
* * * * NewTab = 0
* * * * Set itmX = LV.ListItems(i)
* * * * Printer.Print itmX.Text;
* * * * For j = 1 To LV.ColumnHeaders.Count - 1
* * * * * * NewTab = NewTab + CInt(LV.ColumnHeaders(j).Width * Printer.ScaleWidth / LVWidth)
* * * * * * Printer.CurrentX = NewTab
* * * * * * Printer.Print itmX.SubItems(j);
* * * * Next
* * * * Printer.Print
* * Next
*
End Sub

Gdi+ Animation Loop

$
0
0
Theres a lot of classes and samples about GDI+ to render and manipulate one image, but not so much about multiple rendering on a surface that we use in a loop. Instead of using forms, usercontrols etc, we could use 1 surface (a picturebox) and render everything, from background images, effects, interfaces, mouse arrow etc.

the purpose of this thread is to learn more about this, if anyone of you have nice tricks.
i also like to optimize things, i dont want to call APIs if I dont need to.
that is why I call GdipCreateFromHDC after CLS one time only at the beginning of the loop.
then all the rendering, and finally GdipDeleteGraphics and refresh as the last line.
for the loop i use the API (timeGetTime and timeBeginPeriod) for more accuracy.
i have a few classes, that contains the handles of different images, but all uses the same GdipCreateFromHDC.
then i use GdipDrawImageRectRectI here and there to render the different images.

now questions. i noticed that "sometimes" desktop composition makes the animation choppy, meaning ,its smoother in IDE. when i build an executable and run it, it gets a bit choppy. but not always and not all computers i try it with. desktop composition is will first render to a memory surface and then render it again to the picturebox, maybe that creates some lag. is there a way to make it more smooth without the need to disable desktop composition?

is it better to use CLS then render the whole surface with a solid background color using GdipDrawImageRectRectI?
each time you call CLS, the hdc changes, using GdipDrawImageRectRectI to fill up the whole area, will not change the hdc, but it will require to render the whole screen with a solid rectangle, that takes time too. what is best in this case?

is there a way to make it faster, while still using GDI (i dont want directx or some 3rd party dll)

Export listview value in excel sheet

$
0
0
I have a listview in my project ...
i need to export all value fron listview in excel sheet in c:\database\report\ how to?
Tks.

Too stupid to fire an event

$
0
0
Hi all,

I have a class 'cls_G_Graphics'.
It shall report the progress to the main form via event.

I declared the event in the class:
Code:

Public Event Progress(ByVal Value As Integer)
The class comes to life like this:
Code:

Set G = New cls_G_Graphics
When it works on something I raise the event somewhere:
Code:

RaiseEvent Progress(Percent_Done)
Doublechecked that this line executes!

In the main form I have:
Code:

Public WithEvents abc As cls_G_Graphics
Code:

Private Sub abc_Progress(ByVal Value As Integer)
 Debug.Print "abc_Progress", Value
End Sub

---

The event doesn't come in.
What can be wrong?

I don't understand this, as in other classes I have similar events, and they do work. Couldn't find a logical difference.

Karl

[RESOLVED] Too stupid to fire an event

$
0
0
Hi all,

I have a class 'cls_G_Graphics'.
It shall report the progress to the main form via event.

I declared the event in the class:
Code:

Public Event Progress(ByVal Value As Integer)
The class comes to life like this:
Code:

Set G = New cls_G_Graphics
When it works on something I raise the event somewhere:
Code:

RaiseEvent Progress(Percent_Done)
Doublechecked that this line executes!

In the main form I have:
Code:

Public WithEvents abc As cls_G_Graphics
Code:

Private Sub abc_Progress(ByVal Value As Integer)
 Debug.Print "abc_Progress", Value
End Sub

---

The event doesn't come in.
What can be wrong?

I don't understand this, as in other classes I have similar events, and they do work. Couldn't find a logical difference.

Karl

Audio/Video to DLL

$
0
0
Is it possible to compress a numerous Audio/Video file to a DLL? If yes can I still access it in VB 6.0 even though it is compressed? I tried compressing my Audio files into ISO and Windows Media Player but it doesn't seem to find it...

RunAsAdmin just Once?

$
0
0
Hi there,
Steve MacMahon's reg code runs beautifully if the app is run as admin.
If not, the reg keys cannot be opened (at least in W10 1607). Thing is, the app is set up to run as invoked, but it would be nice if it could be run as admin just once initially to set the keys.
Don't think that is possible somehow but any ideas / suggestions / code welcome.
Thanks!

CheckBox in hierarchical flexgrid

$
0
0
Hi

Is possible put checkbox in hierarchical flexgrid ?

if yes , where can I to found a example

Tia

Deleted but Not Deleted Form

$
0
0
Running vb6 was working back and forth between 2 forms. One form disapeared from the project form list. I tried adding it back in with PROJECT/ ADD FORM/ EXISTING and it says the form is already in the database but I can find no reference to it.
I even edited the .vbp file and the form was listed there. I backed up the .vbp file and removed the reference and still have the problem. I have searched for 30 minutes and have found no solution.

Transfer data with dynamic query results

$
0
0
Long time lurker, first time poster:
I am trying to have Access (through VB) produce Excel spreadsheets. Each spreadsheet will contain the same column names, but the underlying data will differ based on where the information came from.
I have a query (query 1) that shows all columns of pricing. I have a second query (query 2) that pulls only the specific sources for the data.
I want my function to use query 2 and loop through the list it provides to write spreadsheets.
So, if query 2 has a total of 4 sources ( src1, src2, src3, src4) I want the program to give me 4 spreadsheets. One sheet will give me all rows in query 1 where the source is equal to src1. Sheet/file 2 will give me all rows in query 1 where the source is equal to src2 and so on.

So far I have been able to set up my code to loop through query 2 and output a sheet/file. However, the parameter of src# are not being considered in writing the file. Instead of Sheet/File1, Sheet/File2, Sheet/File3, and Sheet/File4 I am getting query 1 written 4 times.

What I actually want is for the code to loop. On loop one I should get a file (File1) with all rows from query1 where the source matches the current data in the recordset (src1). Then move to the next record (srcd2)
Loop 2 will give me File2 with all rows from query1 where the source matches the current data in the recordset (src2). Then move to the next record (src3)
Loop 3 will give me File 3 with all row from query 1 where the source matches the current data in the recordset (src3). Then move to the next record (src4).
Loop 4 will give me File 4 with all rows from query 1 where the source matches the current data in the recordset (src4). Then move to the next record (EOF – drop out of loop)

Code is as follows:
Function ExportFilesBySystem()
Dim StrSQL As String
Dim Query1 As Recordset
Dim dbs As Database
Dim rsQuery As DAO.Recordset

Set Query1 = Nothing
Set dbs = CurrentDb
Set rsQuery = dbs.OpenRecordset("Pricing systems", dbOpenDynaset)
Set Query1 = rsQuery


Do Until Query1.EOF

StrSQL = "SELECT [Pricing All Columns].* FROM [Pricing All Columns] INNER JOIN Query1 ON [Pricing All Columns].[Source System ID] Order by [Pricing All Columns].[Source System ID];"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Pricing All Columns", "H:\ Defect Tickets - " & Format(Now, "yyyymm") & ".xlsx", True
Query1.MoveNext
Loop

Set Query1 = Nothing

End Function


The do loop actually works, however, I have not been able to get the transfer line to perform the SQL that links the 2 queries and use this resulting information to export for the file. I threw in the query “Pricing All Columns” just to test the loop.

I want the file name to include the source(src#) so I will have a different file for each source. File name should be Defect Tickets – src1 - yyyymm

Any help will be greatly appreciated.
Thanks
Viewing all 21308 articles
Browse latest View live


Latest Images

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