During the form's Load() procedure you would Open the file for Input, Clear() the list box, then simply call Input # on the file to get a line and AddItem() to get it into the list, for each line.
If you're wondering how to know how many items there are, you should write out the number of strings (using the list box's ListCount property) to the file as the first line. Then, when you read it back in, the first thing you read is the number of lines remaining in the file to add to the list box...
I have developed a very simple d3dim object creating and picking routine working quite well. On the other hand, rotation and translation do not work together.On either of them the object starts from different locations.
if u can help me please contact and i'll send my little code to you as well.
I am searching for insight on the relative benefits / downsides to using the "As Any" data type in VB. My assumption is that CPU cycles are taken in order to resolve the data types at runtime vs. the use of a stronger type declaration, but I have no numbers telling me that is the case. Any insight appreciated
Au contraire. VB will do no type checking on an "As Any" variable (although it still needs to figure out what it's passing in order to know how to pass it). I don't think you need to worry about CPU cycles here. It's better to worry about how "As Any" will impact your code readability. If you have an API that takes one or more "As Any" arguments, is it always clear what, how and why you are passing what you're passing?
As Any is mainly useful for APIs with arguments like lParam in SendMessage that can be basically anything. Always strong type if you can, but avoid the "multiple overloads" mess for an API (like so many people do with SendMessage).
I am looking for a way to import a C++ class (exported from a DLL) in a VB or VBA project. I know how to work with "declare" for exported functions and with COM but the requirement I have is for a C++ class.
Thanks in advance!!!!!!!!
I need to draw a Equilateral triangle, and also rotate it and bounce it off the screen, i have seem this done before, but i dont know ehere to start,
any help in pointing me in the right direction, and any code samples would be nice
I don't have time to do the details... but,
to give you a clue: What you need to do is host the directx7 library by making a 'reference (via the object browser) first, even though the machines use DX8 'cause thats where direct draw is, OK?
In your code you'll have to:
Private MyDX7 as NEW vbDXlib.DirectX7
Private MyDirectDraw as vbDXlib.DirectDraw7
set MyDirectDraw = MyDX7.DreateDirectDraw7
the trick is that DX7 HAS to be created 'as new'
THEN you get DirectDraw (in-directly) which you then use some UserDefinedTypes (UDT's) to initialize a 'primary_surface' and the 1st 'offscreen_surface'. All this just to get a page flippin scheme so your stuff draws REAL_FAST... before you call your bitmap (of any shape you desire) into a 2nd 'offscreen_surface' using:
-which is a holder in memory for your 'sprite' as some call would say. You then use DirectDraw's
super cool graphics methods to paint rotated versions of the sprite (to the current degree) on a 4th 'offscreen_surface' before dumping that 4th surface to the 1st 'offscreen' surface, so that the picture will be there when the 'Form1_repaint' is called by the Operating_Sys or your animating timer control's ticker event.... Get the DirectX8 sdk and look at the vb-Billboard sample. Really, it shows you exactly what you are trying to do 'cept they made their whirly-gig go in a circle. You'll have to do the bouncing yourself, but the hard parts will be taken care of. You'll be pleasently supprised with the performance, even on a 200mmx or so you could get >45 fps especially if you have a flat color (black?) background so you don't have to clip.
PS: Try using this basic structure for gradient backgrounds, use a 128x128 bitmap created in say... ulead photoImpact's magic gradient (they have a 30 day demo for free) or other graphics package. That size is great 'cause you won't see ANY pixel lines even when the form streches it full screen, unlike the windows desktop... and it re-paints faster than you can do a loop! »geeky ain't I...
"As New" has no speed benefit and it can actually be dangerous in some cases. Declaring the variable and then using "Set x = New Y" is exactly the same thing and is a better coding practice.
What you're trying to explain here (I think) is that late binding (Dim x As Object) is far slower than early binding or semi-late binding.
We're loading some additional ActiveX references into our project, but it's causing 429 errors in other ActiveX objects (like grid controls) that have previously worked just fine. The VB Run-time environment won't run, and forget trying to compile anything.
We've tried moving the priority of the references up and down, but that doesn't help, except we uncovered a DAO 3.5/ADO 2.0 conflict. Any suggestions?
Can any one tell me some good testing tools for VB COM?
Also, can one please elaborate where can the pitfalls in a VB COM be?
Also can one one send me a sample code in which there is a memory leak in VB? (ie how to create a memory leak in VB programme)
Thanx in advance,
I would like to know whether VB5.0 supports DAO? Also I need to read more than 10,000 records from a file and hence manipulate it.Which is the best method of read available with VB 5.0?If i go for binary read, i need to use the OPEN method and if it is text read can i go for Filesystemobject?
If it is a text read, which will give more performance, FSO or the open method?
I am using a number of collections and classes in my application.Will it affect the performance?
Can i be able to increase the performance by using DAO recordsets instead of Collections?
Please give me a reply
1) Yes DAO is available in VB 5 . ofcorse in VB 4 , DAO was the prefered way of working with databases . but why not to consider ADO which is also avaialbe under VB 5
2) I add another method , text file access as a OLEDB data source . it is a very convinient task using DAO . you will have all the luxery of ADO and Recordset in your program without a single line of code . I think it is more important to considet parsing speed of your file ( spliting in collections , sorting , ... ) than just reading speed . using ADO you can use ADODB::Recordset as a collection with sorting/parsing/searching capabilities . there is a great article on this topic in MSDN .
3) using VB code for parsing , searching or sorting is not as fast as you might desire . besides you have to do it all in your code .
4) Using DAO recordsets is a good choice too . but again you have to read the text file and parse as different fields , then write into recordset . use ADODB::Recordet to eliminate all these steps .
i want to create an offline e-book on cdrom...
so i am looking for a possibility to start IE customized??
I'd like to sort my spreadsheet so that I have duplicates one above the other (there will be two or more) I'd like to get it to do a calculation on a field where a cell has th sme account no. Something like
if ActiveSheet.Cells(1,4).Value = ActiveSheet.CElls(1,7).Value Then
ActiveSheet.Cells(1,7).Value = ((ActiveSheet.Cells(1,5).Value)-(ActiveSheet.Cells(2,5).Value ))
ActiveSheetRows(x).Delete End If
So if there are two rows with the same account no it will calc the contents. Id theres three it wil calc the three etc. Then it will delete all but the row with the answer in. Then move on to the next rows in the sheet and carry on from there.
Anyone have an inkling?
I can get it to look at a single rows values and set a format then delete all rows without the format but this isn't what I need:
'Write formula to first cell
'Copy the formula onto all cells
Selection.AutoFill Destination:=Worksheets(UserInput).Range("L1:L4000"), Type:=xlFillDefault
'Find all rows where 0 has been set and delete them
num = 0
On Error Resume Next
Selection.Find(What:="0", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
If Err.Number = 91 Then
RowNo = ActiveCell.Row
I am using input boxes to enter data into a spreadsheet. But my problem is that if the user makes an error then they can't go back. This is partly because after the user has input the data my code puts their data into variable and then does various calculations with it before putting the result into defined cells.
Does anyone know how I could put in a user update if they right click the cell where they have made an error? The new data would then have to be refrshed through the rest of the code. Heres an example of some of the code
Private Sub Workbook_Open()
Dim mydate As Date
Dim baldate As Date
Dim duedate As Date
Dim todate As Date
Dim TheDate As Date ' Declare variables.
mydate = Date
ActiveSheet.Cells(15, 1).Value = mydate
rentac = Application.InputBox(Prompt:="Enter rent account number", Default:="1234567", Type:=1)
tenant = Application.InputBox(Prompt:="Enter name of tenant", Default:="Tenant", Type:=2)
adda = Application.InputBox(Prompt:="Enter house no and street, eg 1 Walnut Street", Default:="1 Walnut Street", Type:=2)
addb = Application.InputBox(Prompt:="Enter name of Town, eg Prudhoe", Default:="Prudhoe", Type:=2)
AddEx = Application.InputBox(Prompt:="Enter additional address lines, eg Hexham", Default:="Prudhoe", Type:=2)
addc = Application.InputBox(Prompt:="Enter name of County, eg Northumberland", Default:="Northumberland", Type:=2)
addd = Application.InputBox(Prompt:="Enter postcode, eg NE42 123", Default:="NE42 123")
bal = Application.InputBox(Prompt:="Enter opening balance", Default:="100.0", Type:=1)
baldate = Application.InputBox(Prompt:="Enter date at which balance applies", Default:="17-06-01", Type:=1)
duedate = Application.InputBox(Prompt:="Enter first charge date eg usually Monday coming ", Default:="18-06-01", Type:=1)
todate = Application.InputBox(Prompt:="Enter last charge date if different from end of year ", Default:="31-03-02", Type:=1)
rent = Application.InputBox(Prompt:="Enter weekly rent", Default:="45.00", Type:=1)
fred = DateDiff("w", duedate, todate)
ActiveSheet.Cells(27, 5).Value = fred + 1
eric = DateDiff("m", duedate, todate)
'ActiveSheet.Cells(27, 9).Value = eric + 1
Dim boolCanExit As Boolean
boolCanExit = True ' will always exit unless the user enters incorrect value
freq = Application.InputBox(Prompt:="Would you like the standing order paid monthly or weekly?", Default:="monthly", Type:=2)
TheDate = Date
Msg = DatePart("m", TheDate) ' Msg now equals the number current month number
dayDate = Date
Ms = DatePart("d", dayDate) 'Ms now equals the current day number
If freq = "monthly" Then
If Ms >= 8 Then
eric = eric - 1
'the annual charge
wop = ActiveSheet.Cells(29, 8).Value
'the annual charge divided by how many periods are left
jazz = wop / (eric + 1)
'the rounded figure
ollie = (Round(jazz, 2) + 0.01)
'the two multiplied together which gets you within pennies of the right fig
thomas = ollie * (eric + 1)
'MsgBox "Next Monday will be " & datTemp
Dim datnex As Date
Dim dated As Date
dated = datTemp
For i = 1 To 7
datnex = DateAdd("d", i, dated)
If Weekday(datnex) = vbMonday Then
ActiveSheet.Cells(88, 3).Value = datnex
'MsgBox "Next Monday will be " & datnex
derrick = DateDiff("w", datTemp, todate)
The problem is that it would be a real pain to reproduce the behaviors of the dropdowns n' such...
However it wouldn't be hard for you to code an ad-in thing-IE (pun intended) to handle that as a floating_window/toolbar/menu using a custom CommandBar or two... perhaps also utilizing the WebBrowser control. The key is to check out what you get a grip on when you create a new 'add-in' project, by looking in the object browser.