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

any site for the some learning

You can learn here. But you need to list what types of hardware you have. There are several types of cash drawers: serial port connection, those that connect to a receipt printer, etc.

The Typical Card Swipe outputs ASCII Data and mimics a keyboard. You plug them into your USB or PS/2 connection. Some of the older USB models you have to write your own code to extract the data on the stripes. That is much more complicated. Stay away from those.

Pole Displays should come with their own driver and manual.

Until you supply model numbers and brands, it's difficult if not impossible to help you.

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
Private Sub cmdString_Click()
    Dim lngPlace As Long
    Dim strText As String
    
    If IsNumeric(txtDecimal) Then
        strText = txtDecimal
        ' Search for position of Decimal point
        lngPlace = InStr(1, strText, ".", vbTextCompare)
        txtPlaces = vbNullString
        If lngPlace > 0 Then
            txtPlaces = CStr(Len(strText) - lngPlace)
        Else
            txtPlaces = CStr(lngPlace)
        End If
    Else ' Clear out text boxes
        txtDecimal = vbNullString
        txtPlaces = vbNullString
        Exit Sub
    End If
End Sub
hkdani 39 Posting Pro in Training

The code that I gave above is good enough

You're right. The way I mentioned is an alternate way of doing it. I realized that after I posted. :icon_redface:

The code may look easier (shl.SetTime) , but the executable will be larger because of adding the shell libaries.

Give Koolsid the thumbs up.:icon_wink:

hkdani 39 Posting Pro in Training

I want to link my program in vb6 to the system calendar in windows XP by using shell but to be able to do that i need to know the default path or file location of the system calendar ( i was searching all day and still didnt find out what it is)

Option Explicit

Private shl as Shell

Private Sub Form_Load()
     Set shl = New Shell
End Sub

Private Sub Command1_Click
     shl.SetTime
End Sub

You need to add the Microsoft Shell Controls and Automation reference in the Projects/Reference Menu. That will bring up the System Calendar. Is that what you're referring to?

hkdani 39 Posting Pro in Training

Okay, step one. Play by the rules. Or at least try to make sure that you do no damage. Save the original clip region so you can restore it on program exit:

Option Explicit
'  Other types ..... like RECT , Points, blah, blah, blah.
'  blah
Private Screen_RECT as RECT

Private sub Form_Load()
    Dim lReturn as long, 
    lReturn = GetClipCursor(Screen_RECT)
    ' The GetClipCursor API returns the current Clip Region of the cursor: this should be the whole screen area on your monitor at this point.
End Sub
' More Code
' 
'
Private Sub Form_Unload()
   Dim lReturn as long
   lReturn = ClipCursor(Screen_RECT)
   ' That should return the clip region back to normal.
End Sub

but when I compile the exe the rectangle it limits is bigger than the form

The GetClientRect API returns only the client area of the window in which the cursor will move. In regards to a normal VB Form, that means the area inside the borders not including the title bar.
So you need the handle to the Window (Me.hWnd) and you need to declare a RECT Type to store client area Dim CLIENT_RECT as RECT .

However, the four values of this RECT will not be in Screen Coordinates: the Top and Left Value will always be zero. The Right and Bottom properties will be the width and height of the client area in relation to the 0,0 origin (Top and Left). This poses a problem to the ClipCursor API since …

hkdani 39 Posting Pro in Training

Well then you can load VB program in Dependency Walker. That should tell you where VB is breaking down.

hkdani 39 Posting Pro in Training

Here, this should work. You can modify it to suit your needs.
It appears the GetWindowRect API is the way to go. This limits the cursor to the active windows screen coordinates. But I imagine you can set your RECT type to whatever you like. But it's good practice to find the original Screen Boundaries and then reset those boundaries on unloading the form.

Option Explicit

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private ScreenRect As RECT

Private Declare Function GetClipCursor Lib "user32" _
   (lprc As RECT) As Long
Private Declare Function GetWindowRect Lib "user32" _
   (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ClipCursor Lib "user32" _
   (lpRect As Any) As Long


Private Sub cmdCursor_Click()
   Dim MyRect As RECT, lngReturn As Long
   lngReturn = GetClipCursor(MyRect)
   Debug.Print MyRect.Top, MyRect.Left, MyRect.Bottom, MyRect.Right
   
End Sub

Private Sub cmdWindowRect_Click()
   Dim WindowRect As RECT, lngReturn As Long, lngHandle As Long
   Dim intCounter As Integer
   lngHandle = Me.hwnd
   lstResults.Clear
   lngReturn = GetWindowRect(lngHandle, WindowRect)
   
   With WindowRect
      lstResults.AddItem "Top: " & .Top
      lstResults.AddItem "Left: " & .Left
      lstResults.AddItem "Right: " & .Right
      lstResults.AddItem "Bottom: " & .Bottom
   End With
   
   ' Clip cursor to current Window rectangle
   lngReturn = ClipCursor(WindowRect)
End Sub

Private Sub Form_Load()
   Dim lngReturn As Long
   lngReturn = GetClipCursor(ScreenRect)
   stbScreen.Panels(1).Text = ScreenRect.Right & ", " & ScreenRect.Bottom
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Dim lngReturn  As Long
   lngReturn = ClipCursor(ScreenRect)
End Sub
hkdani 39 Posting Pro in Training

WHAT DANIWEB.COM MEMBERS ARE MADE OF !

You're a part of DANI.WEB.

Try that dependency walker. You just run your program inside of the Dependency Walker Program and it will output exactly what happens and where.

The actual program name is called Depends.exe Open your executable. Start Profiling (F7) Save the results. That will be a file with extension .dwi (Dependency Walker Information?). Post that file and that should help out quite a bit.

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

MessageBox.Show

You're in the wrong forum. But that's ok, VB.Net is about the same as VB6.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MessageBox.Show("Welcome, to my Calculator", "Welcome", MessageBoxButtons.OK)
End Sub
hkdani 39 Posting Pro in Training

Sounds like you have an ActiveX control that was updated or unregistered by VS2008.

You can try this tool to isolate the problem. It should give you the exact answer.
http://www.dependencywalker.com/

Or just try reinstalling VB6.

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

Well, let's start from base 1. What is the end goal of this code? What exactly is the program trying to achieve?

Good programming practice identifies the function, the purpose, give some pseudo logic on how they hope to achieve their end goal.

' Function: LimitTheCursor
' Purpose: Keep the cursor within a certain area.
' Pseudo Logic: Establish the Client area, Limit the cursor area to 
' that region.
' Method: Use Window API calls
'   ClipCursor, GetClientRect, ClientToScreen, OffsetRect

the rectangle it limits is bigger than the form also if I change the start up position of the form from windows default to center screen the clip area stays in default windows position- any ideas?

From looking at the purposes of the API calls in your code, I would guess you don't need the second or the third: ClientToScreen, or OffsetRect.

I'm guessing you just need to establish the Rect with the first call, and then call your ClipCursor using your established Rect structure.

The ClientToScreen API just converts client coordinates to Screen coordinates. The OffsetRect just changes the RECT coordinates to a different location. I don't see how using those 2 APIs coincides with your stated purpose.

The clip area probably stays in the default area because when you load the program, the RECT values loaded are the default values. The program then changes to center the form, but your code has not taken that into consideration.

You probably should redine …

hkdani 39 Posting Pro in Training

It's lovely that people are sooooo nice.

Well, a typical VB6 noob does not even mess with APIs. He probably doesn't even know what an API is. As a noob, I know I didn't. You have surpassed my noobian beginnings. For whatever that's worth.

And then you have even modified the API call. This is something as an experienced programmer I wouldn't even imagine doing. So as a noob, you have showed great acumen, insight, and intelligence.

I hope you feel better.

hkdani 39 Posting Pro in Training

Noob, just use the API viewer in VB and paste and copy the functions, types, or constants in your program.

If you're a noob, why are you messing with APIs anyway?

hkdani 39 Posting Pro in Training

In the first place, I would say you should be using functions and not subs for your APIs. That way you can deal with errors. You can't deal with any errors, if you don't have a function that returns a value.

Private Declare Function OffsetRect Lib "user32" _
    (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
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

This code is just for one of the aspects: the left position. But the principle is the same for the top position. And if you want, the height and the width.

Use ratios to find the value that you need. In each situation, you need 4 values. One value has to be calculated.

On loading you can extract the original height and width of your form. And on a resize event, you can extract the new size and width of your form.

The values that you might want to change are the left, the top, the width, and height positions of your controls. You don't need a picture box to manage your controls. The new top, left, height, and width positions can be calculated with ratios based on its previous position.

Here's one formula for finding the new left position using ratios:
CurrentLeft / CurrentWidth = NewLeft/NewWidth

Use the same principle for calculating a new top position, height, etc.

Option Explicit
Dim lngOrigW As Long, lngOrigH As Long

Private Sub Form_Load()
   lngOrigW = Me.Width
   lngOrigH = Me.Height
End Sub

Private Sub Form_Resize()
On Error GoTo Resize_ERROR
Dim ctl As Control, lngCurLeft As Long, lngCurTop As Long
Dim lngNewLeft As Long, lngNewTop As Long, lngNewWidth As Long, lngNewHeight As Long
Dim lngCurWidth As Long, lngCurHeight As Long
   
   lngCurWidth = Me.Width
      Debug.Print 3, lngCurWidth
   lngCurHeight = Me.Height
      Debug.Print 4, lngCurHeight
   
For Each ctl In Controls
   Select Case TypeName(ctl)
   Case "CommandButton"
      lngCurLeft = ctl.Left
      lngNewLeft = …
hkdani 39 Posting Pro in Training

I need to write the program in VB and not C due to other hardware that will referenced by my program.

That' puzzling. Why should C, which is a more flexible language, present a problem with your situation?

I am a bit confused

I agree.

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

I assume you have Operating System/Hardware networking connection solved. If not, go to the Networking forum first for advice and take care of that first

But for the VB6 part, you can reference the Microsoft Jet Database 3.51, or 3.6 libraries in conjunction with the Microsoft ActiveX Data Objects 2.8 library.

Go to the Project Menu and select References. And check the above mentioned libraries to give your program the ability to share data on a client machine on the user's computer or on the network.

The Microsoft Jet Database provides both client and server capabilities. :)

Of course, if you just want to send data, You don't need a database server, just send and receive files.

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

Did a little research. But I believe what you need to do is to deal with your file as a Binary File. And then you need to Bitshift your data in some kind of a loop to examine it. Unfortunately, VB6 does not have a bitshift operator. But there are alternatives.

Do a google search. These couple words should give you some good examples.

Bitshift VB6

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

what i need to know is the code for manipulating the bit because as u all knows that LSB insertion plays with all the bits stuff..

Two things would be helpful:

1. Give us some example of data that you want to work with.

2. What expected outcome you wish to see from this data.

Without that info, it's pretty hard to help.

Comatose commented: Don't Egg Him On. -2
hkdani 39 Posting Pro in Training

Item cannot be found in the collection corresponding to the requested name or ordinal.

Please, be specific. What item?
if while in the Immediate Window you try this, then

?rsDetail.Fields("requistion_no")

you should see the value of the field. If not, then you may have the name spelled wrong. Check your recordset field names, to see if the field you're looking for actually exists as you have it spelled.

Also put a break at this line, hit F8 to advance one line and see in the Immediate Window if you can pull up any values: rsOrder.Open sqlQueryOrder, con, adOpenDynamic, adLockOptimistic

' Immediate Window
?rsOrder.Fields.Count

Should tell you if your open statement worked by showing you that there actually exist fields in your recordset. You can then

MoveNext
?rsOrder.Fields("SomeFieldName")

in the immediate window to see if you're actually getting your data.

hkdani 39 Posting Pro in Training

OS will always print to the Default printer.

Debasisdas is absolutely right, as usual.

But I take it when you're saying the app is determining which printer to print, you feel that your user is hemmed in and has no choice of his own to choose which printer?

Good programming always lets the user make his own choice, if possible. In most cases with printing, you're limited to the installed printers on the Windows operating system.

I would use the Printers Collection object in VB6 to find them as follows:

dim prn as Printer, intIndex as Integer
dim iMyPrinters() as integer ' an array of installed printer Indexes
dim strPrinters() as string
intIndex = 0

for each prn in Printers
   debug.print prn.name, intIndex
   
   Redim Preserve iMyPrinters(intIndex)
   Redim Preserve strPrinters(intIndex)
   
   iMyPrinters(intIndex)= 0
   strPrinters(intIndex) = prn.Name
   intIndex = intIndex + 1
next

That code's off the top of my head-- i.e. it may not be accurate. But that should give you a general idea of how you determine what printers are on the system. Once you've decided which printer you want to use through code, then let the user set the printer to the printer of his choice:

Set Printer = intIndex

Of course, you'll have to write code to determine which is the correct index number to use. The printers index ranges from from 0 to Printers.Count-1.

hkdani 39 Posting Pro in Training

MsgBox("requistion no is already exists")

That line of code shouldn't work, period.
You should leave out the parenthesis.

MsgBox "Requisition number already exists", vbInformation, "Requisition Status"

Or

dim intMessage as integer

intMessage = MsgBox("Requisition number already exists.")

Other than that, if you could put a break point at that line and post what the values from ReqNo.Text = rsDetail.Fields("requistion_no") yield, that would be helpful in debugging this.

hkdani 39 Posting Pro in Training

I would use a do until loop. That way the code will only be executed only when there is a line in the text file. That should avoid the error that you mentioned.

Dim IntCounter as integer
Open "Incorrect.txt" For Input As #2
Do until EOF(2)
    Line Input #2, ....
    ...


Loop

Also, I would look at your code inside the loop: Loading(1, Ansread).

I would say that the first element of the array should be Loading(0, Ansread)

The Multi Dimensional arrays as you have them declared actually have 3 first elements (0, 1, 2) and 9 second elements (0, 1, 2, ....., 8). The first value of the Arrays declared as you have coded starts with 0: e.g. Loading (0, 0).

If you want to start with 1, you must be explicit in VB6. But I don't really have enough info from your code to determine if that is your actual problem. This is just a guess. So I couldn't really give you a solid answer here.

Dim strArray(1 to 2, 1 to 8) as String

Also, you might consider changing your code with regards to your variable Ansread declared as a Variant. You can probably get away with it; but since you're dealing with arrays that will increase with integer or long values, why use a variant variable: use an integer variable. I think you're just asking for trouble there.

But I'm assuming that Ansread has already been determined from code that …

hkdani 39 Posting Pro in Training

Input Output

name_123 Valid
name123 Valid
123name invalid
123_name invalid

Don't really know what you're criteria for a valid filename is since you didn't mention the criteria: that might be helpful. But it appears that you 're not allowed to start the name with a number?

Private sub CheckName()

dim strName as String

strName = txtInput

if isNumeric(left(strName, 1)) then
   msgbox "Invalid Name", vbInformation, "String Validation"
Else
   msbBox "Valid Name", vbInformation, "String Validation"
Endif
End sub()
hkdani 39 Posting Pro in Training

If you want to run another thread in VB6 that's independent of your main program, you should write an ActiveX exe file that will take on its own independent thread.

Microsoft in their MSDN documentation recommends using an out of process ActiveX exe.

The fact that an out-of-process component runs in its own process means that a client can tell it to do something, and then go about its business while the component does the work. When such a system is properly set up, the component can tell the client when the task is done using an asynchronous notification, as explained in "Asynchronous Call-Backs and Events" in "Building Code Components."

These aren't really that hard to program. But you might want to go through their examples found in the MSDN CD's or on the archives for MSDN on the internet.

hkdani 39 Posting Pro in Training

I know all about event handling. This is not necessary and I'm not sure why you believe it is.

Windows is an event driven environment.

I know that I can disable right-click

I'd be interested in your future post about how you are able to do this.

I am almost positiive (sic) that they do.

If you knew, you wouldn't be saying almost. Almost only counts in horseshoes.

I don't know how to capture the event that the user highlights, right-clicks, and selects "Copy" from the menu.

You can't capture that in VB6 let alone from VBA. And I really doubt Access casts some magic functionality spell on VBA giving it more power than VB6.

I'll leave you alone.

hkdani 39 Posting Pro in Training

I think the suggestions that I provided are simplier and more portable than that. This is a distributed MDE. Do you really want me to package a DLL with it for some small copy feature?

Once again, I appreciate your assistance.

It is a small feature, but you have to catch the WindowMessages generated by the Windows operating system to avert the current behavior of the menu click and replace it with your own.

There are all kinds of Windows messages generated by a Windows program and that's just one of the messages. And you may not even be able to avoid that behavior, because that may be completely controlled by the executable file.

It's like a sandbox. You can play inside the sandbox, but you're not allowed to play outside that sandbox.

Visual Basic is just that: basic. What you're asking to accomplish goes beyond the basics.

hkdani 39 Posting Pro in Training

Okay. The problem is in the Select Case CurrentDay , ..... End Select section.

As someone nicely pointed out in a previous post, you could have a possibility of 6 weeks in a month, if Day 1 fell on a Saturday (maybe even a Friday with 31 days?). That's why there are 6 cases: Case 1, Case 2, Case 3, ...., Case 6.

You simply have to determine that your tests in each of the 6 cases make sense.

Case 1 should always be from 1 to intFirstSaturday.
If you'll look at the code

' First Saturday should always be the following:
    intFirstSaturday = 8 - intFirstDay

You should be able to find the actual day for the First Saturday of the month with that formula. The Day() fundtion returns which day of the week a certain day happens to fall on: Sunday, Monday, Tuesday, Wednesday, etc. So, if Day(#3/1/2009#) returns a value of 1, then 8 - 1 = 7: March 7, is Saturday, in other words.

That's the first test for Case 1

Case 2 should start with the Day after the first Saturday or intFirstSaturday + 1 or as in the above code: IntFirstDayWeekTwo.

We're testing from Sunday to Saturday or a period of 7 days. So

Case (intFirstDayWeekTwo) to (intFirstDayWeekTwo + 6 )

Ah, I think I see the error. It begins in Case 3. I think I should be adding 7 instead of 6. So that …

hkdani 39 Posting Pro in Training

But still it has problem . As for example for 5 january 2009 it is week 2 but it returns week 1 . Please check it.

I'm leaving that up to you. I thought it was right, but testing it I did see a few bugs. I think it's a logic error on my part, but then again I also thought maybe the control itself wasn't working right. But I really doubt the control is giving the problem, it's probably me.

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

I don't know how to capture the event that the user highlights, right-clicks, and selects "Copy" from the menu.

You can do that using the Windows API's and C Programming. Your problem is that you're in VB6. That's why they say, if you want finer grain control over what occurs in the program, you should use C or C++!

But I believe this is what you want: You need to write your own DLL in C to handle what you're asking, you need to register that into the VB6 Programming Environment so you can load it as a DLL from the Project Reference Menu, and then just use your DLL in VB6.

It's really simple, if you have 5 years experience in C Programming, 2 years programming Windows APIs, and a little patience: the patience of Job.

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

but I imagine that this forum should yield accurate information for a simple query such as this.

Try the mousedown or mouseUP event. They are about the same as the KeyUP and KeyDown Events.

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim intButton as Integer
intButton = Button
Select case intButton
Case 1 ' Left Mouse Button

Case 2 ' Right Mouse Button
' Write Your Code Here
Case 4 ' Middle Mouse Button
'
Case Else
'
End Select
End Sub

The Shift parameter reflects whether the Shift, Ctl, or Alt key were pressed in conjunction with the Mouse Button: with values of 1, 2, and 4 respectively.

But this only covers for clicks on the Active Form. You might have to deal with Buttons, Pictures, etc. I don't know. And some of those controls may not have a built in MouseDown or MouseUp Event. That's where you'll have to get into the Window API's. It get's complicated fast.

hkdani 39 Posting Pro in Training

You probably want to use the KeyUp event on the particular form on which the Ctl+C event occurs. You use this event to test for a combination of keys. You also need to enable the KeyPreview property on the form.

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim intKC as integer, intShift as Integer, intResult as integer

intKC = KeyCode
intShift = Shift
intResult = intKC + intShift

if intResult = 69 then
   ' Do whatever you want here
   Keycode = vbnullstring ' Disables the Control C functional 
                                        ' Replace it with your own.
end if
End Sub

The Shift Code has a value of either 1,2, or 4 when used in a key combination. C will be detected as 67 and the value of the control Key is 2 in the combination scenario.