hkdani 39 Posting Pro in Training

Just click inside the gray column to the left of Call Main_ON() .
Put a question mark before the variable name and press enter in the Immediate Window. The next line should show the value of the variable.


Immediate Window
-----------------------------------
?strUserName
JoeUser

I would put your debug.print right after the if varFound = True Then line.

if varFound = True then
    debug.print strUserName, strPassWord, ' etc. .................
hkdani 39 Posting Pro in Training

BUT I didnt enter a username OR password.

Put a break at Call Main_ON and use your immediate window to check the values of strUserName , strPassword and the values in your arrNames.

hkdani 39 Posting Pro in Training

It says
"Next without For"

You left out an End if in the Nested If ...End if

If strUsername = arrNames(intArray, 0) Then
            If strPassword = arrNames(intArray, 1) Then
                varFound = True
                Exit For
            ' This is where you should have an End if  
        End If
hkdani 39 Posting Pro in Training

I don't see anywhere in your code where you load the values for array. I would go ahead and do that in the load event. As long as you have the array declared in the beginning

Option Explicit
Dim arrNames(3, 1) As String

then your array values will be available through the life of the program.

But as VB5 said, you need to loop through your array to see if the person has enter a valid match. But since you're checking for a password, you also need to provide in your program a place for your user to input not only his name, but his password.

I would suggest a couple of text boxes for that purpose.
Since you already know the bounds of your array you can just loop throught it.

Private Sub CheckUserPassword ()
Dim i as integer
Dim bFound as Boolean
bFound = False

for i = 0 to 3
    if arrNames(i, 0) = strUserName then
        if arrNames(i,1) = strPassWord then
              ' Success
              bFound = True
              exit for ' this will exit the loop
        end if
    end if
next i ' The next statement just increments the variable by one

' what to do if invalid username or password
if bFound = False then
     ' code to notify user
end if
End sub()

Ubound just returns the upper boundary of an array. In your case, you already know what it is. The Ubound property is usually used with Dynamic Arrays

Returns aLong …

hkdani 39 Posting Pro in Training
Private Sub Form_Load()
'Disables password box
Call Disable_Passwordbox
Dim varUsername As String
Dim varPassword As String
varUsername = txtUsername.Text
varPassword = txtPassword.Text
End Sub

In the first place, your variables varUserName and varPassword only have scope or a lifetime during the Form_load() procedure. As soon as the form is finished loading, those variables are history.

To check passwords, you need at least two items to check against: (1) The user, and (2) the password. Your array only stores the name. You might want a two dimensional array declared at the beginning of your form:

Option Explicit
Private ArrayNames(3,1) as String

Then you could assign a password in the Array that could easily be recalled later

Private Sub Form_Load()
    strNames(0, 0) = "Joe"
    strNames(0, 1) = "JoePass"

    strNames(1, 0) = "Jeff"
    strNames(1, 1) = "JeffPass"
    
    ' etc. ............
End Sub
hkdani 39 Posting Pro in Training

I would say that your problem stems from .rsCommand1.State <> 0 Not every property and method is supported by every type of Database: In your case an Access database.

It looks like the State property is not supported.

hkdani 39 Posting Pro in Training

please tell me ...

The thread has been marked solved. I guess you figured it out?

hkdani 39 Posting Pro in Training
' Use the Change Event of the text box
' In this example txtDateChange is the other text box.
Private Sub txtDateChange_Change()
    Dim strText, vNewDate As Variant, intEntered As Integer
    strText = txtDateChange
    ' Test for correct input: this does not deal with negative values.
    If IsNumeric(strText) Then
        intEntered = CInt(strText)
        ' Use the DateAdd Function: 
        vNewDate = DateAdd("m", intEntered, CDate(txtDate1))
        ' Enter the new date in your text box with the date         
         txtDate1 = Format(vNewDate, "Short Date")
    End if
End Sub
hkdani 39 Posting Pro in Training
' Use the Change Event of the text box
Private Sub txtDateChange_Change()
    Dim strText, vNewDate As Variant, intEntered As Integer
    strText = txtDateChange
    
If IsNumeric(strText) Then
        intEntered = CInt(strText)
        vNewDate = DateAdd("m", intEntered, CDate(txtDate1))
        txtDate1 = Format(vNewDate, "Short Date")
    End if
End Sub
hkdani 39 Posting Pro in Training

I don't know. It's hard to tell from the info you've given, but really the only 2 values you need to keep track of are the current width and the current height of the form. You notice I track them immediately upon the Form_Load event and at the end of the resize event.

And you should also notice that there is an On Error Resume Next statement at the beginning of the Form_Resize event. Usually, those negative values come from minimizing the window or coming up with a value that doesn't make sense. You may have to write an error loop to catch those negative values in the resize event and make sure that the current width and current height values of the form are not negative. Once they change to negative, you may have problems changing them back.

hkdani 39 Posting Pro in Training

In a form_resize event your form will resize. What will not resize and relocate automatically are your controls. They will remain at the locations originally specified in the design view.

So your problem is how do I write code to resize and relocate my controls?

Use ratios. Use ratios. Use ratios. Use ratios. Use ratios. Use algebra. Use algebra. Use Equations.

This is one example.

Find the new left position:

Ratio Formula
Original Width/ New Width = Original Left/ New Left

You know the original width of your form. Let's say it is 2200. After a resize event, it changes to 2800. And you know the current left position of your control:

Dim lngLeft as long
 lngLeft = MyControl.Left

Use your formula:
2200 / 2800 = lngLeft / New Left
The only value you don't know is New Left.

Cross Multiply to solve a ratio Equation: Multiply tops * bottoms. If you know algebra, then you should be able to figure this out.


But in the example it works like this:

2200 * New Left = 2800 * lngLeft


To solve this equation isolate NewLeft:

NewLeft = (2800 * lngLeft) / 2200

You have just solved for the left position of one control.

MyControl.left  = NewLeft

Use the same principle for solving for the top value, but use a different formula:

Original Height / New Height = lngTop …

hkdani 39 Posting Pro in Training

But if you want to use code, then you can use the Windows API function SendMessage .

Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const SC_TASKLIST = &HF130&


Private Sub Command1_Click()
    Dim lngReturn As Long
    lngReturn = SendMessage(Me.hwnd, WM_SYSCOMMAND, SC_TASKLIST, 0)
End Sub
hkdani 39 Posting Pro in Training

Once you load the Shell Controls and Automation reference, then you should find all these constants available for your use and you can just use the autocompletion feature of your IDE: just type ssf and then Ctl + Space to see the constants appear in your code window.
These are a list of the constants available for your use:

ssfDESKTOP Desktop folder.
ssfPROGRAMS File system folder that contains the items in the Programs folder on the Start menu.
ssfCONTROLS Control Panel folder.
ssfPRINTERS Printers folder.
ssfPERSONAL File system folder that contains the user's documents.
ssfFAVORITES Favorites folder.
ssfSTARTUP Startup folder on the Start menu.
ssfRECENT Folder that contains shortcuts to the user's most recently used documents.
ssfSENDTO Folder that contains the items that are added to the Send To menu.
ssfBITBUCKET Recycle Bin.
ssfSTARTMENU Folder that contains the items that are displayed on the Start menu.
ssfDESKTOPDIRECTORY File system folder that contains the items on the desktop.
ssfDRIVES My Computer.
ssfNETWORK Network Neighborhood.
ssfNETHOOD File system folder that contains items displayed inside the Network Neighborhood.
ssfFONTS Folder that contains the installed fonts.
ssfTEMPLATES File system folder that contains document templates. MSDN

If you just want to open the start menu, why not just click the start menu button?

hkdani 39 Posting Pro in Training

thanks. but, dear tell me about my computer. it works with control panel.

Press the Power Button. That's a good one :) I like that one. Well, you weren't very explicit.

But I think this is what you want.

Add the Shell Controls and Automation reference in the Projects/Reference Menu by clicking on that item.

dim MyShell as Shell

Private sub form_load()
set MyShell = New Shell
     MyShell.Explore &H11 '  For My Computer
     MyShell.Explore &H3  '  For Control Panel
end sub

Private sub form_unload()
Set MyShell = Nothing
end sub()

Hopefully, that's enough to get you going. You can take the code from the form_load event and stick it in the appropriate Command Button.

Comatose commented: Very Good Work Here. +12
hkdani 39 Posting Pro in Training

Okay, then all you need is the last line of the readfile...

That's a great solution, vb5. Didn't know that there was a Split function. That function make sure makes life simple.

Returns a zero-based, one-dimensionalarray containing a specified number of substrings. MSDN documenation

Lindsey, that should easily solve the first requirement of splitting up the string into an array. Now you should be able to proceed to solve your remaining two dilemnas: (1) parse out the xml tags leaving your desired info, and (2) separating specific tagged lines to post in your forum.

After using the Split function and verifying that it returns the data for which you're looking, I would solve the second problem first. Then you can concentrate on removing the xml tags.
But just take it one step at a time. You can only solve one problem at a time. It's easy to become overwhelmed, if you try to solve the whole problem at once.

It's usually good practice to first write out what they call Psuedo Logic in your comments:

' Step 1: Convert String into Array
' Step 2: Separate Specific tagged lines
'   If ..... yada, yada, yada
' etc., .....

By the yard it's hard. By the inch it's a cinch.

hkdani 39 Posting Pro in Training

Is there any way to do it without creating a new file? ...
The only way I have been able to read in the email is to put it into a string.

Lindsey, you're right. You shouldn't make your task any harder than it should be. That's one of the first rules in programming: Keep it simple stupid (KISS). The intent of a software program should not be to impress the world with the programmer's brilliance, rather its intent shoule be to achieve a specific purpose.

Nevertheless, I would say that your first step should be to put the e-mail into a string array so that you could deal with each line separately. Your e-mail text probably has several lines and you must determine how to break that up into lines so that you can analyze each line separately.

You might post the value of that string variable that you read in your program. The answer to your problem lies within the structure of that value; but it's hard to advise you without that information.

hkdani 39 Posting Pro in Training

Hello there. I am witting a program in vba/access and I have a string coming in. I need to go through the string and look for specific tags and return the rest of the line. So lets say:
"I went"
"to the"
"park"

I need to tell the program to look for "to" and return the string "to the" The string is from a letter and I need to pick out specific lines and fill them into an forum.
Thank you so much for your help!

I would say the first step is to put those lines of strings into a string array using kind of a loop. What type of loop and how to do this is kind of hard to help you with without more details.

Dim strInput() as String, intStringCount as integer
Dim strReceived as String
Dim strSearch as String, intCounter as integer
'  intStringCount = 0

While  '   ..............
' Read a line into your [I]strReceived[/I] variable

' Code to do the above

' dimension your string array
Redim strInput(intStringCount)
' Assign that line into the array
strInput(intStringCount) = strReceived

' increment your counter
intStringCount = intStringCount + 1
WEnd ' '''''''''''''''''''''''''''''''''

' Identify your tag

strSearch = txtSearch.text

' Loop through the string Array till you find the tag

for intCounter = 0 intStringCount
   ' Use one of string functions like Instr, Mid$, etc to find the tag
   if strSearch = txtSearch.text then
      ' Code to do what you need …
hkdani 39 Posting Pro in Training

but what about if I am going to get the value between time like 9:00am to 2:00pm? It < or > will still going to work?

I guess the simple answer is yes it will work.
The point is that a Date when used by the compiler is just a number

Here's what VB6 does in Single and Double conversion of a date value:

?cDbl(now)
39876.9616087963
?Csng(now)
39876.96

If you have no desire to delve into the deep for fear of drowning, just understand that dtpPicker.Value will return a Value that you can use with the < > logical comparators.

handling a time is a bit hard. =)

Understand that a time is actually a date. Or understand that a time can be stored in a Date Type.

So, if you pulled that 9:00 AM value from your DatePicker Control, make sure you're using dtpPicker.Value for your date: that value is a Year, Month, Day, SEcond, etc. value.

You don't have to convert it into a Double or Single number, the compiler does that for you when it does the comparison. All you have to understand is 2 things: (1) using the dtpPicker.Value property for you return value is crucial, and (2) yes it will work.

The brain is like a muscle. The more you use it, the more it grows.

hkdani 39 Posting Pro in Training

It < or > will still going to work?

A Date Value is a Year, Month, and Minute, second, millisecond, etc. value. The VB6 compiler can break it down into a number with double Precision:

dblDate as Double
dblDate = cDbl(Now)
Debug.Print dbldate

Try running that and the result should answer your question. Date Values begin at Zero or Saturday, December 30, 1899.

Try this in the immediate Pane:

?format(cdate(0), "long date")

?clng(cDate(0))
hkdani 39 Posting Pro in Training

I assume you already have DateOne and DateTwo?

You just use if then logic

if (dtPickerInput >  Dateone) And (dtPickerInput < DateTwo) then
   ' Whatever you want to code, if test passes.
else 
   msgBox "Out of Range", vbInformation, "Range Error"
Endif

The word between should fit the logic above, unless you're required to include the occasion when it's >= or <=. If so, just use >= and <= for your logical comparisons.

hkdani 39 Posting Pro in Training

Your Sequel code should look something like this

Dim strSQL as string 
strSQL = _
"SELECT MyDates.* " & _  
"FROM YearlyDates " & _
"WHERE MyDates " & _
"BETWEEN  DateOne AND DateTwo"

You might have to monkey with setting up the date format: e.g. cDate("3/1/2009")

But you also need to establish an exact day for a reference point for your 6:00 AM and 6:00 PM. Which means you need a Month, a Day, and Year to make this work.

Don't know which type of Database you're using, but the above is more or less what you're looking for in a SQL string.

The DatePicker Value property is the Value you're probably looking to use in your program.

Dim DateOne as Date, DateTwo as Date

DateOne = DTPicker1.Value
DateTwo = DTPicker2.Value

That should give you a Date Value you can use.

Hank

hkdani 39 Posting Pro in Training

It still seems to me that if I have opened a connection from my project to an associated database that there should be some way of using that connection across all the forms in that project.(Surely there is a logical way of transferring the properties of the objects involved across the board)

Class Modules are the way to go, I would say.

You'll notice that Class Modules have a Data Source and a Data Binding Property.

You write the code to initialize the ADO Database objects and to terminate or close them in the class module.

You can then access this class module from anywhere in your project. Usually, in a form.

Option Explicit
Dim MyCounter as cmCounter


Private Sub Form_Load
set MyCounter = new cmCounter
'
'
End sub


Private Sub Form_Unload
' Close out your class module
set MyCounter = nothing

End sub

Check out the MSDN documentation, if you have the CD's Look for the section Accessing Data Using Visual Basic under the Data Access Guide.

Using Visual Basic/Data Access Guide/Accessing Data Using Visual Basic

Hank

hkdani 39 Posting Pro in Training

You should try using the form name first when using it from form2: e.g.
form1.MyRs

It's best to use class modules instead of regular modules. Class modules have better support for Data Objects.

Hank

hkdani 39 Posting Pro in Training

("SELECT * from tblLecture where arlNumber = '" & lblLECNUM & "' ")

SELECT * from tblLecture WHERE alrNumber=" & cstr(lblLECNUM)

Don't think that will make much difference. But it's a little clearer.

there's my code, im having a error "DATA TYPE MISMATCH IN CRITERIA EXPRESSION "
but i cnt and no idea where it is.... and im still finding it

That particular error usually pops up when you have a NULL value coming from your form. Try using an error checking code before you run the SEQUEL statement.

If lblLECNUM.Caption <> vbNullString then
    ' Execute Code for Database
Else
    ' Do not execute Code for Database
Endif
hawisme000 commented: thx for helping =) +1
hkdani 39 Posting Pro in Training

Everything else is just algebra and logic.

You need to have one established reference point: That's the value you derive from using the above API's and finding the current time using the Now function.

Lets' call that value lngValueA. Save that value and use it as a reference point for your minutes:seconds:milleseconds.

Once you have established that reference point. You need to come up with a formula to calculate How many minutes, how many seconds, and how many fractional seconds.

This is just basic algebra.

hkdani 39 Posting Pro in Training

its starting from a number like 1774796

It always helps to read the manual. In this case: the documentation which is freely available online from MSDN for this API.

how can i make it actually count down and start from 8 minutes??

http://support.microsoft.com/kb/172338

hkdani 39 Posting Pro in Training

This code, when the timer property for interval is set at 1 millisecond, should give you resolution of the user's system timer.

This came out to be about 15 milliseconds on a 2.4 GHz pentium4

Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim blnStart As Boolean

Private Sub Command1_Click()
   Timer1.Enabled = Not Timer1.Enabled
End Sub

Private Sub Form_Load()
   On Error GoTo Load_ERROR
   blnStart = True
   Exit Sub
Load_ERROR:
   MsgBox Err.Description, vbInformation, "eRROR"
End Sub

Private Sub Timer1_Timer()
Static CurrentTickCount As Long
Dim lngTickCount As Long, lngDifference As Long
If blnStart = True Then
   lngTickCount = GetTickCount
   CurrentTickCount = 0
   blnStart = False
Else
   lngTickCount = GetTickCount
End If
If CurrentTickCount = lngTickCount Then
   
   CurrentTickCount = lngTickCount
   lngTickCount = 0
Else
   Label1.Caption = lngTickCount
   lngDifference = lngTickCount - CurrentTickCount
   Debug.Print lngDifference
   CurrentTickCount = lngTickCount
End If

End Sub
hkdani 39 Posting Pro in Training

This API function Return a time in miliSecond for each time called.
you can use it.

That API depends on the resolution of of the operating system's timer.
That could be anywhere from 9 to 100 milliseconds.

If the user requires a resolution of 1 millisecond, then you'll have to use the other API's to determine if the running CPU has that capability: hence the necessity of using the QueryPerformanceFrequency and QueryPerformanceCounter APIs.

hkdani 39 Posting Pro in Training

(rs!Titles(Where(rs!Teacher = teachers.Text)))

You've put the cart before the horse.

Your first step is to open the recordset using a sequel statement string: rs.open ( source, etc., , , )

Your sequel statement will go in the source parameter as a string

Dim strSequel as string

strSequel = "SELECT Titles.Teacher from Titles WHERE Teacher='" & teachers.text & "'"

rs.Open strSequel, etc. , , ,

I'm taking for granted the name of the table in your recordset is Titles and the Field you are searching is Teacher.

A good download for you would be the Microsoft Active X data objects Software Development Kit (SDK). The current release is at 2.8. It has a very well written manual which give examples on how to open up databases.

Once you open the database using the above sequel string, you should have a recordset of Titles where the Teacher is the name you have entered in the teachers text box control.

I could just give you the code in a zip file. But I think you would benefit more in the long run by downloading the SDK, reading the documentation. But if you get stuck, let us know.

Hank

hkdani 39 Posting Pro in Training

i know how to make a simple timer with seconds. but how to put minutes n milliseconds?? it should look like this
minutes:seconds:milliseconds

Using the 'Now' function with VB6 (this is a VB6 forum) gives you the current time. However, this will only give you the time in seconds.

Even if you convert the Now to a double precision value (which you'll have to use obtain milleseconds), the best you will get is still a change in the visible value every second.


So what you need to use is the Windows API 'QueryPerformanceCounter' in your program to obtain a higher precision of accuracy. To find how much precision your CPU will provide you use the 'QueryPerformanceFrequency' API

The degree of precision depends on your CPU and how simple you can keep your code.

Private Type LARGE_INTEGER
    LowPart As Long
    HighPart As Long
End Type

Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long

Private Declare Function 

QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long

Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long

I've given you a start. But here's the pseudo logic you'll need:

Determine your CPU's capabilities with the QueryPerformanceFrequency

Create a loop to provide a value to use for your millisecond display.

And you need to provide some method to get yourself out of the loop.

I'll leave the rest to you. But that should get you started.

Hank

hkdani 39 Posting Pro in Training
Option Explicit
   Private Const MARQUEE = "This is a scrolling Marquee."
   Dim intLength As Integer
   Dim strMarquee As String

Private Sub Form_Load()
   lblMarquee.Caption = MARQUEE
   intLength = Len(MARQUEE)
   strMarquee = MARQUEE
End Sub


Private Sub tmrMarquee_Timer()
   Dim strFirstCharacter As String
   ' Find the current first character
   strFirstCharacter = Mid$(strMarquee, 1, 1)
   ' Remove the First Character
   strMarquee = Right(strMarquee, intLength - 1)
   ' Add it to the end
   strMarquee = strMarquee & strFirstCharacter
   lblMarquee.Caption = strMarquee
End Sub

You just need to ensure that your timer is enabled and have the interval property set to something like 750 (milliseconds). You can get by with one timer. In this example, the timer's name is tmrMarquee

Hank

hkdani 39 Posting Pro in Training

Save both values into 2 different variables.

Convert both to uppercase. Test to see if they're true. When in doubt. Use your immediate window: <Ctl +G>

This is false
----------------------------------------
Immediate
?"Hah"="HAH"
False


This is true
----------------------------------------
Immediate
?"HAH"="HAH"
True


--------------------
Immediate

?"GOOD GRIEF"="Good Grief"
False

?(ucase("GOOD GRIEF")=ucase("Good Grief"))
True

hkdani 39 Posting Pro in Training

if theres a "Haw" already inside the field "Username"

then i wanna add "HAW" (all CAPS)

Hah, hah. That's really funny:)

You have earned my first official Good Grief!

Hah, hah, hah.

I can't stop laughing!

hkdani 39 Posting Pro in Training

thanks for your input. However, is there such a syntax like
(Toggle Plain Text)

database.movefirst

Weeeeellllllllllllllllll. That's a deep subject.

Option Explicit
Dim database as ADODB.Recordset

Private Sub Form_Load()
Set database = new ADODB.Recordset

database.MoveFirst
End Sub

I haven't tried the code. These are just quick notes to illustrate what you need to do. But if you're able to recognize what is proper syntax, I think you should have no problem figuring out how to properly declare and instantiate your own recordset variable objects.

But that's a good point. "database" isn't a very good name. And it may not even be allowed as a variable, if it's one of those words that are not allowed to be used.

Usually, you want to declare a Recordset Object Variable with something that begins with rst:

Dim rstCustomers as ADODB.recordset

Using your format and looping through to delete the database content may delete the tables which I do want to delete.

You said you wanted to delete contents.

There is a difference between a table and a recordset. You can have a table without a recordset. But you can't have a recordset wtihout a table.

In other words, your table will still be there with its fields. You just won't have any records.

A table is a database object You can delete a table object, but that would take different code. The code above is just for deleting one row of the table at …

hkdani 39 Posting Pro in Training

hi venkat,
I am really sorry.I dont mean to irritate u.is func syntax something like this??
type def
App.Path = "E:\LATEST"
end type

App.Path is a built in value stemming from the prewritten function 'App.'

App.Path should be used on the right hand side of the '=' operator: not on the left hand side like you have it.

Dim strPath as string

strPath = App.Path

Your program should have a default installation path. Microsoft recommends using the 'Program Files' Directory and then the name of your program: e.g. c:\Program Files\My Application\

If you want to change the path your program uses, that type of information should go into your registry:

Option Explicit
Dim strStartUpPath as string
strStartUpPath = APP.path  
' Or
strStartUpPath = strMyChoice

Private Sub Form_Load()
strStartUpPath = GetSetting("MY APP", "Install Defaults", "StartUpPath", "C:\Program FIles\My App")


End sub
hkdani 39 Posting Pro in Training

I assume that you have some idea of how to work with Access databases in VB6. If not, let me know.

But I would use the End of File property (EOF) in a loop to delete the records in the database.

With MyDatabase
      .movefirst
      While not .EOF
        .delete
        .movenext  
      Wend
End with

And would probably use the same method to load them from database 'A' to database 'B'.
You could declare some variables to use to keep the values of the fields. This would allow for error checking. Or you could just transfer them directly

DatabaseB.MoveFirst
While DatabaseB.EOF <> True
DatabaseA.AddNew

DatabaseA.Field("Name") = DataBaseB.Field("Name")
......
......
...... etc,

DatbaseA.Update
DataBaseB.MoveNext
Wend

Hank

hkdani 39 Posting Pro in Training

what i want is there will be a msgbox that will tell theres already "MyName" on my table,

Don't really understand what you want?

If you already have accessed the data, you should already know that the MyName Field exists.

"MyNaMe" or "MYNAME" (have diff Uppercase and Lowercase charater)
is will still recognize it as a simple "MyName"

Microsoft doesn't care if you use Uppercase or Lower Case when referring to field names in a database. It just cares if the letters match.

Hank

hkdani 39 Posting Pro in Training
Dim lblfname (10) As String
Dim lblsname (10) as string
Dim lblgrosssalary (10) as Integer
Dim lblnetwage (10) as Integer

Yes, that will declare an array with 11 values (0 -10). But when you use Dim, the Array's scope is limited to the form. You can only use that variable within your form.

Use the Public declaration to make it available to other forma within your project

Option Explicit
Public lblsname(10) as String
....

Then you'll have to access it using the name of the form first like so:

frmInput.lblsname(0) = "MyInput"

You can avoid this if you add a module to your project and declare the Public Array in that module. Then you can access it without having to name the name of the form.

Hank

hkdani 39 Posting Pro in Training

Well, you could just send us your code. And we would just send it back to you finished. But the whole point of these forums is to help the person.

If you find yourself stuck, you need to sweat a little. The brain is like other muscles in the sense that you need to use it before it can grow stronger.

You have reached an impasse. You need to sweat.

hkdani 39 Posting Pro in Training

You can use the Public type as a means of storage. You might want to add a regular module (not a class module) to your product to declare it in that section as I mentioned before. You could also declare a Public Variable ArrayCounter for your array in the same module.

But you need to change the Array Counter as new employee information is entered for each different employee. As long as you don't close your program down, the information will remain in memory. I don't know how you determine when your done collecting your information, but at that point, if you're using the Public type Array, you should enter that information at that time:

Your first input form (frmInput) will copy the info into the Array.

Private Sub Update_Array()
With MyEmployees(ArrayCounter)
   .FirstName = txtFirstName.text
   .SurName = txtSurName.text
   .HoursWorked = txtHoursWorked.text
   .SalaryRate = txtSalaryRate.text
End with
' Update the counter for the next employee
ArrayCounter= ArrayCounter + 1

Now you can use that info once its stored in the Public Type to copy into your other forms.

With MyEmployees(ArrayCounter)
  frmwagw.labelEmp1Name = .FirstName
  frmwagw.labelEmp1Surname = .SurName
  ' etc.
  frmummary.labelEmp1Name = .FirstName
  frmummary.labelEmp1SurName = .SurName
  ' etc
End with
hkdani 39 Posting Pro in Training

You have to update the Array.

MyEmployees(0) Would be your first employee

MyEmployees(1) Would be your second employee, etc.

Using the different values in the array, you have separate storage area for each employee. Once you've stored the values corresponding to one member, it can be later accessed by remembering the Array Value.

Or you can even search the Array until you find the Name you're looking for using a loop.

MyEmployees(1).Name


MyEmployees(2).Name

hkdani 39 Posting Pro in Training

I would declare a Public Array of your own type: You can declare the amount in the array to begin with or assign the amount dynamically with a Redim statement.

Option Explicit
Public Type Employee
   Salary As Currency
   FirstName As String
   SurName As String
   HoursWorked As Single
End Type
Dim MyEmployees(10) As Employee

Hank

hkdani 39 Posting Pro in Training

Just a few general suggestions.

Sometimes VB6 has problems dealing with threads outside of its own code.

For instance, suppose you have code to access a database within a sub procedure. You have about 20 lines of code in that sub. At line 15 you access the database. The database is accessed; but you find that the following 5 lines in that sub routine were never executed.

Strange, but it is a documented problem with VB6 when accesing databases in the middle of a subroutine. The solution might be to end the sub at the end of the call to the database (line 15) and then make another sub routine to handle the next five lines.

So, try breaking up your code into smaller blocks. You have three calls to an excel spread sheet in the same subroutine. I guess that's what you have. FORTWICB, I'm guessing, is probably some function you have that returns a string.
I wouldn't stick all these in the same subroutine.

And I'm not too sure about your code for your conditional statements:

if lstPostcode = .....

You should break in the middle of your code while its running and see in the debug window if you can actually retrieve a value with the code the way you have it written.

--------------------------------------------------
Immediate
debug.print lstPostcode

Qpido commented: Helpful person +1
hkdani 39 Posting Pro in Training

These are 2 codes I'm now using seperately, because if I put them together they won't do anything.

Looks like you're making it too hard.
Try sticking your second code inside of a timer that's disabled

' after your first code
' set the interval property to about 750
timer1.enabled

Private Sub Timer1_Timer()
'
Dim strListValue As String, sngPercentage As Single
   strListValue = lstDiesel.List(lstDiesel.ListIndex)
   ' Check for numeric value to avoid run time error
   If IsNumeric(strListValue) Then
      Text1 = ""
      Text1 = strListValue
    End If
    
If lstDiesel.SelCount = lstDiesel.ListCount Then
lstPrijs.Selected(Index) = 0
End If

Text3 = ""
'
timer1.enabled = false

End Sub
hkdani 39 Posting Pro in Training

Hey guys first time learning VB6 and i have to do a Hangman project for my Gr 10 class

You have several errors in your English.

Hey, guys. This is the first time learning Visual Basic 6.0 (VB6). And I have to do a hangman project for my GR-10 class.

This is a more acceptable sentence structure.

You know, the mind is like a muscle: the more you exercise it, the stronger it becomes.

I'm not counting the spelling errors. They are too numerous to mention. If you hope to be of help to someone in the future, please first learn to help yourself by taking on the responsibilities incumbent upon a responsible descendant of Adam. If you will be faithful in the little things of life, people will call upon you for help in the bigger things.


But in answer to your problem ................

Your posted code is quite impressive. The style is excellent.

And I really think with a little effort you will come up with the answer.

hkdani 39 Posting Pro in Training

"MyApp", "MySection",MyKey","MyValue"

Try reading the MSDN documentation. Those are just names I made up. You have the freedom to make up your own.

Use regedt32 from the run command: Check the HKEY_CURRENT_USER section: Software/VB and VBA Program Settings

MyApp is a name you give to an application found in the VB and VBA Program settings section

MySection is the name of a sub folder of the Application Name

MyKey is a name you make up for a field

and MyValue is the actual value.

You can search the MSDN.com legacy section if you don't have your own MSDN CD's installed.

hkdani 39 Posting Pro in Training

I've been searching a lot, but couldn't find anything about what I would imagine to be pretty easy.

Private Sub List1_Click()
   Dim strListValue As String, sngPercentage As Single
   strListValue = List1.List(List1.ListIndex)
   ' Check for numeric value to avoid run time error
   If IsNumeric(strListValue) Then
      Text1 = Format(CDec(strListValue) * sngPercentage, "currency")
   End If
End Sub
hkdani 39 Posting Pro in Training

When I click on a number of persons the price is displayed...

But I need a way to change the prices so they must not be in the coding!!!

What is 'they': the prices or the persons?

and i need to save these values on closing of program so that they stay the same next time I open the program!!!

The simplest way to save data without much overhead is to use the registry.
Use the following:

SaveSetting  "MyApp", "MySection", "MyKey", "MyValue"

Use GetSetting to retrieve the data.

You probably want to save the index value. On the form load event you can retrieve that Index Value using GetSetting and then set the Index value with that value. I'm assuming that you already have the prices saved in the list of your properties as well as the values for your combo boxes.