Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

OLE_COLOR Confusion

Hi,Can anyone please explain the format of OLE_COLOR to me?I have the following code:
dim c as OLE_COLORc = &h0000ff00 ' this is what i actually type when using setting c to be green
The '&h0000ff00' becomes '&HFF00' when I move to the next line of code.Why does it get truncated?Also, why is the '&H' needed?Thanks very much,dhartigan

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
I am trying to convert an OLE_Color value to its RGB values. Is there some VB function that can do this?



Is there a way to convert an OLE_COLOR value to an RGB colro value?


What Is The OLE_Color Type For
Can someone explain the OLE_Color variable type to me? Is it used for normal colors (like BackColor) or is it specifically for OLE stuff?

Ole_color Randomize
Hi there im trying to use graphs using teechart but i want to randomize the color for each lets say bar chart. In the method to create a new bar in the chart there is a parameter for an ole_color value now i'd like to know how can i make that randomize the color by writing a lttle method

Ole_color Darken && Lighten
Private Function DLOleColor(SysColor As OLE_COLOR, Effect As Integer) As OLE_COLOR
Dim Color As Long
Dim NewColor As Long
Dim j As Integer

For j = 0 To 2
Color = ((SysColor (256 ^ j)) And 255) + Effect
If Color < 0 Then Color = 0
If Color > 255 Then Color = 255
NewColor = NewColor + (Color * 256 ^ j)
Next j

DLOleColor = NewColor
End Function


DLOleColor(any OLE_color, effect from -255 to +255) return OLE_color

will return darken or lighten color constant

Problem With CreatePen And OLE_COLOR
I'm using this Code to draw a rectangle:

pen = CreatePen(0, 0, m_DisabledColor) '1)
SelectObject .hDC, pen
RoundRect .hDC, 0, 0, .ScaleWidth, .ScaleHeight, 5, 5
DeleteObject pen
IT works fine when the m_disabledcolor isn't any predefined OLE_COLOR,
there the color is correct.
But when I use a color of the OLE_COLOR dialog it's allways black, equal if the selected color is white, blue or anything else.
Know any one a way around it?

OLE_COLOR And Long Color

I'm just courious.
Can I pass long value of a color to property that is defined as OLE_COLOR?
If not, how can I "translate" long color to OLE_COLOR? (I know how can I make OLE_COLOR to Long value. )


How To Get Control Backcolor And Store As OLE_COLOR
Hi all,

I had tried a lot of time but i can't get the solution of my problem.

Now i would like to use a variable as OLE_COLOR to store the backcolor of a

Label. When the user mousemove to the label the Variable will store the

backcolor of the label and the label will change to others color. Following it,

when i mousemove at outside the label, the label backcolor will access the

color store in variable.

How can i do that ?

Thanks for help

Note On COLORREF's, OLE_COLOR's And Long's That Represent Colours
Has anyone ever really wondered about why whenever you set a backcolor, fillcolor or forecolor property (All OLE_COLOR properties, recognisable by the colour picker in VBE) with a long number it gets the colour completely wrong?

Well I have, and after finding very little simplified help on the matter I have decided to make this post with my findings, in an effort to aid those who wish to understand quickly and simply whats going on.

Description of Problem
The basic problem is that a COLORREF (A long that represents a unique colour) is different to an OLE_COLOR in 2 ways. First the 'Major Bit' of an OLE_COLOR represents a system colour (which you don't get in a COLORREF), this isn't the main root of problems though as this bit can merely be discarded when converting.

The main difference however is that an OLE_COLOR is a hexadecimal value of a BGR value, as opposed to RGB for a standard COLORREF. A pickle indeed if you wish to feed long numbers into your background fills!!

So, assuming all the above makes sense you now have a grasp of the problem. So all we need is a little function that can do the conversion for us. So here it is! This function will convert either Colour (It's just a case of reversing the values, in a bitwise manner) to its counterpart. Sweet!

Private Function SwitchColor(OldCol As Long)
Dim Rval As Long, Gval As Long, Bval As Long
Rval = OldCol And 255
Gval = (OldCol And 65280) / 256
Bval = (OldCol And 16711680) / 65536
SwitchColor = (Rval * 65536) + (Gval * 256) + Bval
End Function
I am posting this, as mentioned above, in an effort to share what I have learned. I would very much appreciate any feedback, comments, critism on this info. Also post a reply if you found this helpful at all!



Reg Confusion
Its just an example for me to understand

RegCreateKey "HKEY_CURRENT_USER/test", "WWW", "30"

As you may already noticed, i what to create a "folder" named "test", in that HKEY, with a key named "WWW", with its value "30"

I never worked with the registry... =X

Whats wrong?

Hdc Confusion
I've got a program which draws polygons in a picture window. The first version of the program used Line to draw the polygons, but I want to fill in the ploygons with colour, so I'm using the GDI32 api, and the Polygon command. ie
Polygon hdc, pts(1), 4

One thing I can't figure out is the hdc. If I just have the polygon drawing being activated during a form_resize, and I only want to draw on the form itself, I don't need to specify the hdc, just leave it as 'hdc'.

However, I want to draw in another subroutine, and not draw on the form itself, but instead draw in a picturebox on the form. Ideally, what I'd like to be able to do is hdc = Form1.Picture1, but that won't work.

What do I need to do to specify the drawing location for Polygon?


p.s. It's annoying not being able to search these forums for 'hdc', because that's under the minimum word length for the search routine. Grr.

IF Confusion
I have a section of code I would like to add an IF statement too, but I'm not too sure where. Right now the code looks for the value 'R'. When it finds it, it copies it to a table. I would like the macro to find 'R', and then check the cell beside it to look for a '1'. If the '1' is found then it will copy the data to the table. If the cell beside the 'R' value is blank, then it will skip it and continue.

Thanks for the help, here is my code.

Private Sub ListSearchActive()
Dim R As Range, FindAddress As String
Dim i As Integer

'Set initial value of the variable
i = 4
'Delete the results of previous runs

'Search for all the occurrences of the item
With Range("D3 : D65000")
Set R = .Find(Range("J3").Value, SearchOrder:=xlByColumns, LookAt:=xlPart)
'If a match is found
If Not R Is Nothing Then
'Store the address of the cell where the first match is found in a variable
FindAddress = R.Address
'Copy data to table
With Worksheets("Sheet1").Cells(i, 9)
.Value = R.Offset(0, -3).Value
.Font.Name = "Arial"
.Font.Size = 9
.Font.Underline = xlUnderlineStyleNone
.Font.ColorIndex = 1
.WrapText = False
.HorizontalAlignment = xlLeft
End With
With Worksheets("Sheet1").Cells(i, 10)
.Value = R.Offset(0, -2).Value
.Font.Name = "Arial"
.Font.Size = 9
.Font.Underline = xlUnderlineStyleNone
.Font.ColorIndex = 1
.WrapText = False
.HorizontalAlignment = xlLeft
End With
With Worksheets("Sheet1").Cells(i, 11)
.Value = R.Offset(0, -1).Value
.Font.Name = "Arial"
.Font.Size = 9
.Font.Underline = xlUnderlineStyleNone
.Font.ColorIndex = 1
.WrapText = False
.HorizontalAlignment = xlLeft
End With
With Worksheets("Sheet1").Cells(i, 12)
.Value = R.Value
.Font.Name = "Arial"
.Font.Size = 9
.Font.Underline = xlUnderlineStyleNone
.Font.ColorIndex = 1
.WrapText = False
.HorizontalAlignment = xlLeft
End With

'increase value of the variable with 1
i = i + 1
'Search the next cell with a matching value
Set R = .FindNext(R)
'Loop as long matches are found, and the address of the cell where a match is found,
'is <> as the address of the cell where the first match is found (FindAddress)
Loop While Not R Is Nothing And R.Address <> FindAddress
End If
End With

'Clear memory
Set R = Nothing

End Sub

Thanks for all the help!

i have all my macro vb working very well.... but the problem is that when i open another file that has some sheets with the same name of the the other file my macro start misconfusing everything and stop working... i have already told it to select the rite window but it sttill keeps doing the same mistake! what can i do???

Dir$ Confusion

As part of my program a folder is created on launch and removed upon exit. The program was failing when trying to delete the folder (Permission Denied), and I've managed to narrow it down to the dir$ function in this line:

SetConnection .sTempPath & "" & Dir$(.sTempPath & "*.mdb")

If i type the path in manually it works perfectly:

SetConnection .sTempPath & " estdatabase.mdb"

It seems that the Dir$ function is keeping my folder open. How do I close it?


VB / VBA Confusion.....HELP PLEASE
PLEASE help, I am losing my hair!!!!
I have written an application in VB which performs some calculations, displays them and saves them in an array ( "VEDataArray()" ). The data is also stored in a comma deliminated file which can be opened back up at a later time. I want to be able to graph the data using EXCEL.CHART, but I am running into (newbie) problems.

I created a form( frmGraphData ), and in the form is an OLE EXCEL Chart object ( oleGraphData ). I set up the chart in design mode, and it looks and plots the data correctly. My problem is, I can not get the EXCEL.CHART to updata the data sheet automatically when it is opened.

I have searched and tried examples in the archives to no avail, I am sure it is a simple syntax problem, or I am not putting the code in the right place. When I run the VB executable and open oleGraphData, I can manually refresh the data, and the chart plots correctly. I recorded a MACRO within EXCEL, and when I run it, it charts correctly, but I can not make it refresh data automatically.

I do not know whether to load data in VB, or with VBA, or to record a MACRO.

The EXCEL object work book is called ( VEWorkbook) , the datasheet is called ( VEData ) and the chart is ( VEChart ).

Would it be easier to load data from the array, or from the comma deliminated file?

I understand the VB part ok, and the VBA part ok, but I can not make them work together correctly.

ANY help would be greatly appreciated, or links to appropriate info.



ADO Confusion
I am totally lost. I downloaded and read thru all of the ADO stuff in the FAQ section and that has helped me some. Here is what I am trying to do.
Using VB6,ADO and Access2000
I need to insert data that is stored in VB variables.

Variable Name & DataType

Public DateSelected As Date
Public strSelected As String 'Holds companyName selected from previous SQL
Public CustID As String 'statement assinged to MSHFlexgrid
Public ReminderType As String
Public ReminderText As String

The ADO example only uses one table and uses a Select statement then an Update method.

I cannot figure out how to even begin the select statement(if that is necessary) because most of them are from the VB form, so that I could do the update method. <very confused>
Here are the tables,fields and relationships

TableName FieldName

Customers CustomerID 'autonumber
Reminders ReminderID (autonumer) and CustomerID
ReminderDetails ReminderID

They are releted in this manner ...
Customers.CustomerId >>> Reminders.customerID
Reminders.ReminderID >>> ReminderDetails.ReminderID

I do not want someone to actually provide the answer, rather just explanations. I just need to insert into the ReminderDetails table the info stored in the VB variables AND somehow use the autonumber fields from the related tables.
Thanks for any help

Udt Confusion
hi all, i am quite confused at this type of declaration
Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (_
hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)

Private Type MyType
i As Integer
l As Long
s As String * 8
d As Double
End Type

what does it stand for ? ?? s As String * 8

Little Confusion
select o.customer_fname,i.item_name from oorder as o left outer join customemade as cm on cm.orderid=o.order_id left outer join oordertrans as ot on ot.orderid=o.order_id left outer join item as i on i.item_id=o.itemid or i.item_id=ot.itemid or i.item_id=cm.itemid,ori_user as us Where us.userid = o.customer_id and o.order_id=5

the above query throwing a result like

rajesh rose
rajesh jasmine
rajesh sunflower

but i need a result like

rajesh rose

is it possible mean's plz reply soon....

Cbo Confusion
Hi to all you experts, wish I was too!!!!!!!
Different related Files created in 2 forms, how to populate 2 cbo's for user selection in another form. Is there a predefined source code that is used and if so could someone tell me what it is.

Many Thanks

SQL Confusion
I'm trying to figure out how to write this SQL statement. Could someone give me a hand?

I am looking to Select ALL members of the DAT-X table who have an PC IDNUM = X and then match those against the DAT-Y table by their PC IDNUM against IDNUM to return the NAME field.

The tables contain:
-Contact IDNUM -Name

It seems as though this should be simple, but thus far I have had little success.

Here's my dilema. I find myself always running into problems when using the KeyPress, KeyDown, KeyCode, KeyUp..Can anyone tell me when to use one over the other?? Little confused on this subject. Thanks

For/Next Confusion
Please help!!!
     I am attempting to write a program that prints 10 rows of asterisks on the form, like this:
****, and so on . . .

     I wrote a For/Next statement that uses variable "count" to (supposedly) represent the rows of asterisks; the problem is, I can't figure out how to change the count, which is an Integer, into "*"s, so I can print them (instead of printing this
4, and so on . . .

     I have a feeling that it involves either the Format$ or String$ functions, but I just can't get it to work. Figuring this out will open whole new doors to me (I hope), but it's one of those things that I'm just not seeing. Thank you.


Hex Confusion
Happy Good Friday and hope all has a great Easter...

I have a integer that I am converting to a Hex 10 and 20 convert but 240 gives error ?

dim intTriggerHours1 as long
dim intTriggerHours2 as long
dim intTriggerHours3 as long


intTriggerHours1 = Hex(SystemClock(0))
intTriggerHours2 = Hex(SystemClock(1))
intTriggerHours3 = Hex(SystemClock(2))

VB.6 User, Since 2002
Next Generation Lighting Controls

ListView Confusion
I'm completely new to VB, and want to use a ListView control in a project of mine. I've downloaded a sample from Microsoft, but it seems extremely complicated as it uses TreeView, StatusBar, ProgressBar and ListView all at the same time, so I can't seem to pull out which code applies to the populating of a listview.

So, first, is there any good tutorial on how to use the basic listing features of a listview (My MSDN cd is gone, so I can't look up the basic MS help on it either)? Second, is there an easy way to get data into a listview (from an ADODB.recordset or just any data type)?

INNO Confusion
I ran into the following while deploying my pgm on another machine: "Component titext6.ocx did not register or one of its dependencies is missing or invalid." I think I have narrowed it down to one of the dependencies (tishare6.dll). My INNO code looks like this:

Source: "C:WindowsSystem32 ishare6.dll"; DestDir: "{app}"; Flags: ignoreversion

I manually deleted the .dll and I was able to generate the same error msg. I then tried reinstalling the program but the .dll didn't show up. I manually copied the .dll into the System32 folder and registered it and my pgm works fine.

It appears that INNO did not do what it was supposed to. Am I even close?

More Form Confusion

I have a form that has 5 text boxes and 7 check boxes. How can I get the results to the sheet here is what I started but can't figure out.

Private Sub CommandButton1_Click()
Dim rc As Long, cell As Range, i As Long

rc = Cells(Rows.Count, 1).End(xlUp).Row
If TextBox1 = "" Then
MsgBox "No Blank Fields"
ElseIf TextBox2 = "" Then
MsgBox "No Blank Fields"
ElseIf TextBox3 = "" Then
MsgBox "No Blank Fields"
ElseIf TextBox4 = "" Then
MsgBox "No Blank Fields"
ElseIf TextBox5 = "" Then
MsgBox "No Blank Fields"
For i = 1 To 5
Set cell = Cells(rc + 1, i)
cell = TextBox(i).Text
Next cell
End If

End Sub

I want it to run when the ok button is clicked.


OLE Confusion And Frustration
Please help....before I start throwing my PC out of the window and then myself

I can search a word document but I now want to display that word document in an OLE field instead of opening a new instance of word. But I do not want to use the "insert object" dialog box I would like to select a file from a drop down box and then display the word doc in an ole field.

Loop Confusion
I'm trying to print charts from an Excel workbook that is prepared to accept data from an Access recordset. I'm having trouble finding info about cell ranges. Do the row and column indices start with 1 or 0? Have a look. This runs okay, I think, until you get inside the inner loop.

Private Sub Chart_Click()
On Error GoTo errChart

Dim dbs As Database, rst As Recordset, varNumRows As _
Variant, varArr As Variant
Dim intF As Integer, intR As Integer
Dim wkb As Excel.Workbook

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblSurvey", dbOpenTable)
Set wkb = GetObject("H:showellspdTest.xls")

varNumRows = rst.RecordCount
varArr = rst.GetRows(varNumRows)


For intR = 1 To UBound(varArr, 2) + 1
For intF = 1 To UBound(varArr, 1) + 1
Cells(intR, intF) = varArr(intF - 1, intR - 1) 'PROBLEM HERE


Set dbs = Nothing
Set wkb = Nothing
Exit Sub

MsgBox "Error #" & Err.Number & ": " & Err.Description
Resume exitChart

End Sub
I'm hoping my mistake will be obvious to the trained eye!

Texture Confusion...
My friend made me a few awsome 3D models in 3DS Max 5 and i changed them to .X using conv3ds. Anyways, i noticed that when you are loading the model in your game you need "Textures", he didn't give me any textures... Can i make them from the 3DS file or does he need to give me them?

Help: Checkbox Confusion...
I am trying to use a checkbox, which is located in the sheet(2) in my workbook to be a toggle for a boolean variable (boolOnLineTimeCheck) in my code to do/not do a specific thing. The code for the checkbox is in the class module of the sheet(2).

The goal of my code is mining data from other Excel files and dumping it into sheet(1).

The following is my code for the checkbox

Option Explicit
Sub CheckBox1_Change()
If CheckBox1.Value = True Then
boolOnLineTimeCheck = True
boolOnLineTimeCheck = False
End If
End Sub

The boolOnLineTimeCheck variable is currently dimensioned as Public as follows in my Module1:

Public boolOnLineTimeCheck As Boolean
this is outside of the subroutines on this module.

Then in one of subroutines i have the following code:

If boolOnLineTimeCheck = True Then
If Workbooks(astrFiles(iastrFiles)).Worksheets(intDay).Cells(25, 2).Value < 99.9 Then
GoTo 3
End If
...other stuff that isn't important
end if

The problem is that when i toggle the checkbox it does not change the variable (boolOnLineTimeCheck ) i am trying to use in the last block of code. However, if i click inside the checkbox code and hit F5 it will change the variable to the proper value.

I thought the code behind the checkbox is supposed to excecute automatically when changed when the code routine is called CheckBox1_Change.


Confusion With MID() Function
Hi I am trying to use the following mid function to extract a 6 digit number from a long string of letters and numbers related to pipes in the water network. then I wish to check that the number is not greater than 15.00.

This is how it is set out:

Column A ------------Column B--------Column C
{Long String here}----=MID(A2,54,6)--=IF(B2>15,"Error","OK")

The problem is that the If only ever returns 'Error' despite the value extracted to B2.

What have I done wrong?

Thanks in advance for any help.

Text Box Confusion!!
I have a Form with 20 Boxes. That form is for a Configuration File that has 20 items.

It has 3 different status's.
1st: Create a Configuration File
2nd: Edit Configuration File
3rd: View Configuration Filw

It works Great in the 1st and 3rd usages but not in the 2nd.

In the 2nd(Edit) I can not delete, or backspace any of the characters in any of the Boxes. How can that happen.
None of the coding changes! How can you prvent even a singular text box from deleting its characters or backspacing them into oblivion?

VAL Confusion (Simple I Think)
Is this code right?

Val(label.caption) + Val(form1.label1.caption) = Val(form1.label1.caption)

For some reason this is confusing. I want the value of label.caption to be added into the value of form1.label.caption. I just can't seem to get it too work.

If label.caption = 1
form1.label1.caption = 10


form1.label.caption = 11

Lisbox Confusion
on my form i have a textbox and a listbox and i want to be able to change the fontsize on both of them.

but when i use

text1.fontsize = text1.fontsize + 2
list1.fontsize = text1.fontsize
the listbox height decreases
can someone please tell me why this is happening and how to stop it


Property Set Confusion
I'm still having problems instantiating objects in class modules. In a BAS module I have:
Public SN2 As New SuperNetClass
Public SN1 As New SuperNetClass01
Public ActualValue As Boolean
Public TickValue As Boolean
Public HighLowCategories As Boolean

and in the form Main I have:
Private Sub Form_Load()
Debug.Print "ActualValue = " & ActualValue
Debug.Print "TickValue = " & TickValue
Debug.Print "ActualValue = " & ActualValue
Debug.Print "TickValue = " & TickValue
End Sub

and then in SuperNetClass01:
Private Sub Class_Initialize()
Debug.Print "SuperNetClass01 is born"
End Sub

Private Sub Class_Terminate()
Debug.Print "SuperNetClass01 is dead"
End Sub

Public Sub Actual()
ActualValue = True
TickValue = False
Set SN1 = Nothing
End Sub
Public Sub Tick()
ActualValue = False
TickValue = True
Set SN1 = Nothing
End Sub

and then in SuperNetClass:
Private Sub Class_Initialize()
Debug.Print "SuperNetClass is born"
End Sub

Private Sub Class_Terminate()
Debug.Print "SuperNetClass is dead"
End Sub

Public Property Set HighLow(ByVal newSN1 As SN1)
HighLowCategories = True
Set SN2 = Nothing
End Property

When I try to run it, which is supposed to set the public boolean ActualValue to true, TickValue to false, and HighLowCategories to true, I get user defined type not defined. I'm trying to set HighLow to be SN1 objects, which can either be Tick or Actual.
What am I doing wrong? I've tried putting the SN1 declaration in the BAS module as well as the SuperNet class module. Doesn't make any difference. I want to put in 3 more Properties to go along with HighLow, where each one sets a different boolean variable, and then I want to do another class that instantiates SN2 several times with several other properties etc... Argh!
Thanks for any help.

CDONTS Confusion
I know how to code to send email. When at work I can send using the DLL BUT at home I have an SMTP Server on WIN 2000 Prof. I created a new domain that is my att&t SMTP address but the code still won't send my emails.

What is up?!

CurDir Confusion
Does CurDir return the director where the .exe is installed? If not, what command will tell you the directory where the .exe is running?

Delphi To VB Confusion
I got some Delphi code i am looking over, and since im not too much of a pro i ran into some code that was confusing me
Ok first of all, nil. Is there a way to express nil in vb?
Next, an api call has a variable that was declared as a SECURITY_ATTRIBUTES type (no ByVal), but the delphi code simply passes nil. How do i do this in vb?
Next, on an API call that had a buffer (no ByVal) declared as Any, the delphi code passes it like this: Pointer(SomePChar)
the variable somepchar is declared as a pchar data type.
Finally, on a API Call with a parameter declared as a long data type (in vb) the delphi code passes somthing like this: @SomeDWORD

Any help on this to turn it into vb code would be great!

Recordset Confusion
Among other things I'm trying to set the maxvalue of a progress bar to the number of records in a recordset. The problem I'm having is once I open the recordset the RecordCount and AbsolutePosition are always -1. It doesn't matter what sort of move I do with the recordset. i.e. MoveLast, MoveNext, etc.. Those values are always -1 before I loop through the recordset, while I loop through the recordset, and when I am done looping through the recordset. Does anyone know why this is?
I'm using an ADODB.Recordset. The conn.Provider is "IBMDA400", which is an OLE DB provider for our AS/400 DB2 databases. My recordset cursor location is AdUseServer. My Cursor Type is adOpenForwardOnly, and my LockType is adLockReadOnly. Could any of those settings be what is causing me problems? I am not having any problems accessing the records otherwise.

Code Confusion
I'm trying to add a record and I'm using ADO but there is a problem with my code. I don't know what I'm doing wrong or where to put anything...please help me to clean this code up so it will work.

Dim db As Connection
Dim rs As Recordset
Dim db1 As Connection
Dim rs1 As Recordset
Dim db2 As Connection
Dim rs2 As Recordset
Dim val1 As Integer
Dim val2 As Integer
Dim val3 As Integer
Dim Val4 As Integer
Dim sql As String

Private Sub cmdAdd1_Click()
If txtName.Text <> "" And txtAddress.Text <> "" And txtPhone.Text <> "" And txtArrival <> "" Then
If MsgBox("Make a New Reservation?", vbQuestion + vbYesNo, "Add Record?") = vbYes Then
MsgBox "Reservation Made. Room alloted for visitor", vbInformation, "Reservation Made"
End If
End If
txtName.Text = ""
txtAddress.Text = ""
txtPhone.Text = ""
txtArrival.Text = ""
End Sub

Private Sub AddReservation()
Set rs1 = New Recordset
rs1.Open "SELECT address, arrivaldate, confirmed, date, name, phone FROM tblReservations"
rs1.AddNew '.AddNew method used to add a new record
rs1!Date = txtDate.Text
rs1!Name = txtName.Text 'Assigning the values to the fields
rs1!Address = txtAddress.Text
rs1!Phone = txtPhone.Text
rs1!arrivaldate = txtArrival.Text
rs1!confirmed = ChkArrival.Value
rs1.Update 'Updates the recordset after changes have been made

rs1.Close 'Closes the recordset

Set rs1 = Nothing ' Reclaims any resources that have been used.
End Sub

Private Sub Form_Load()
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "db1.mdb" & ";Persist Security Info=False"
Set rs = New Recordset
rs.Open "SELECT arrivaldate, arrivaltime, name, sex, age, address, city, pincode, phone, roomno FROM tblCheckin", db, adOpenStatic, adLockOptimistic
Set db1 = New Connection
db1.CursorLocation = adUseClient
db1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "db1.mdb" & ";Persist Security Info=False"
Set rs1 = New Recordset
rs1.Open = "SELECT address, arrivaldate, confirmed, date, name, phone FROM tblReservations"
Set db2 = New Connection
db2.CursorLocation = adUseClient
db2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "db1.mdb" & ";Persist Security Info=False"
Set rs2 = New Recordset
rs2.Open "SELECT name, address, phone, roomno, checkindate, checkoutdate, daysstayed, amount FROM tblCheckout", db, adOpenStatic, adLockOptimistic
txtDate.Text = Date
Text20.Text = Date
Text1.Text = Date
CmdUpdate1.Enabled = False
cmdRemove.Enabled = False
cmdUpdate.Enabled = False
Text16.Enabled = False
Text17.Enabled = False
Text18.Enabled = False
Text19.Enabled = False
Text21.Enabled = False
Text22.Enabled = False
Text23.Enabled = False
Text24.Enabled = False
Text25.Enabled = False
cmdSave.Enabled = False
cmdBill.Enabled = False
cmdClear.Enabled = False
Text28.Enabled = False
End Sub

While And Nextloop Confusion
hi what's wrong with this piece of code?

Private Sub Check_year(year As Integer)
Dim x As Integer
Dim Datum_temp As Date
Dim Datum_klant As Date
With rstInfo
While .EOF = False
For x = 1 To 12
Datum_temp = DateSerial(year, x, 1)
Datum_klant = DateSerial(rstInfo![bijdrage voldaan], rstInfo![peilcode], 1)
If Datum_temp = Datum_klant Then
If Months(x) = 1 Then
rstInfo![aandacht1] = True
End If
End If
Next x
Debug.Print rstInfo![code]
End With
End Sub

i mean when i get rid of the for next loop then everything works fine but when i put it back in it goes only to the first record and stops after that.

DC Use && Cleanup Confusion
in the process of making a new game, i've decided to use alot of bitmaps & API calls i'm not completely comfortable with. i'm trying to load an image from a file into memory, use that to bitblt to a back buffer, then to the display, then finally clean up after myself. well i've done a fair amount of searching & its only confused me. ever website i went to had a different method.

one went along the lines of:

Public Function LoadDC(hParentDC As Long, iFile As String) As Long
'loads a picturefile, then turns it into a dc
Dim temp As IPictureDisp
Dim DC As Long

DC = CreateCompatibleDC(hParentDC)

Set temp = LoadPicture(iFile)
SelectObject DC, temp

LoadDC = DC

DeleteObject temp
End Function

PicDC = LoadDC(FrontDC, App.Path + "/somebitmap.bmp")

PicDC = Empty

another one used GetObject to load the bitmap into a UDT & cleaned up with:

Private Sub Class_Terminate()
Dim lresult As Long

lresult = DeleteObject(SelectObject(iImageDC, hbmImageOld))

' When this object is destroyed, destroy the Device Contexts that
' are being used.

Call DeleteDC(iImageDC) ' delete the image DC
End Sub
and yet another one used SaveDC & RestorDC... 2 APIs i wasn't even aware of...

so many different methods!! is there anything wrong with these methods? i'm new at creating bitmaps & DCs so i don't know the "correct" method, but which one might be appropriate for an intermediate programmer?

Byval Confusion
Hi all,
I am learning to use API's but feel a bit confused with the way "ByVal" is used in the function Declare statement.By definition of a function if "ByVal" is used then the original argument is not affected.Here's my examle:

Option Explicit

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub Command1_Click()
Dim retstr As String * 255
Dim retval As Long

retstr = "hello world"
retval = GetWindowsDirectory(retstr, 255)

Label1.Caption = retstr
End Sub

This obviously generates the output "C"WINDOWS" as expected.

My question is why should the string variable 'retstr' contain anything other than "hello world" since the argument is being passed as "ByVal"?

Check Box Confusion!
this one is quite tricky for my form i have 3 checkbox's ...check1,check2 and check3 ..i tried writing a script such that when check1 is clicked it unchecks check2 and check3 ..similary when check2 and check 3 are clicked it uncheck's the remaining check box's...i am able to uncheck one box but not both ..can any body write a code to do so..

Confusion In Printing With VB 6.0
i dont't know if this is related to VB or just an error in my setting but whenever i print some text in my printer using VB... the printer doesn't print anything unless i code "printer.NewPage" then after that code, in the next page, i can now print my data.... thank you

Runtime 13 Confusion
Ok this confuses me. In my project the components i feel that are relevant to my problem are a timer and a winsock. ok i was readin interval variable for timer1 from form2 when form1 loads:

Private Sub Form_Load()
Timer1.interval = Form2.Text1.text
end sub

now this worked fine untill i added a second winsock. Even though the second winsock does not in anyway interfere with either timer1 or form2.text1. It shows runtime error 13, anyone know why?

Hello all:

I'm brand new to VB and I've been working on programming the parallel port to do my bidding and test out a microchip my boss designed. Strangely enough, the parallel port was the easy part, the hard part for me has been getting the results of the test, i.e. the output, to be displayed to the user in a concise manner.

I had been using msgbox (requiring the user to click ok 256 times to complete the test). Next I moved up to a textbox, but each new test (256 tests in the whole cycle) replaced the old text in the textbox, and there wasn't any output file for the customer to examine the data on the microchip.

So now I am in the process of figuring out the FileSystemObject thingy, hoping that I can design a sub which will print all data as lines in a text file, and can be referenced from my main form.

Heres what I've got so far-

PHP Code:

Private Sub addline(Optional line As String = "", Optional Color As Long = vbBlack)
    Set fsoTest = New FileSystemObject
    Set tsTest = fsoTest.OpenTextFile("C:mytestfile.txt", ForWriting, True)
    tsTest.WriteLine ()
End Sub

obviously the tstest.writeline needs something in the parentheses, but I'm not sure what to put... Can anyone help me get this thing to print text to a file? Once I can do that I should be able to figure out how to load it into my RichTextBox and display my precious precious data...

Thank you!

Message Box Confusion
I am using message box for taking confirmation from user.

the code is:-
If MsgBox("Are you sure?", vbYesNo Or vbQuestion, "Confirmation") = vbYes Then
Cancel = False
Cancel = True
End If

Confusion is:-
Why the default close button (which has cross mark on it such as windows close button) on the message box is disabled after this code.
and what i have to do to reactivate it.

Timer Confusion
I'm suffering from Timer Confusion.

I have added a Timer to my Form to help operate a Progress Bar.

I want the timer to only start when a user clicks a button.

For some reason, the timer starts on form load. How do I restrict the timer to just the click of a button?


Private Sub lblLaunch_Click()

Load Form1


End Sub


Private Sub Timer1_Timer()

Static iValue As Double
Dim i As Long

Timer1.Enabled = True

iValue = iValue + 1

If iValue = 100 Then Timer1.Enabled = False

progBar.Value = iValue

End Sub

Thanks for any suggestions!!!

Copyright 2005-08, All rights reserved