SCBWV 71 Junior Poster

Good example using the Sieve of Eratosthenes algorithm - http://www.codeguru.com/columns/vb/article.php/c6575

SCBWV 71 Junior Poster

Are you using VBA in Access or Visual Basic 6?

SCBWV 71 Junior Poster

Try Format$(Number, "##-####"). If you want leading zeros, use Format$(Number, "00-####") or Format$(Number, "00-0000")

To be consistent, you can make the "00-0000" a public constant.

SCBWV 71 Junior Poster

Form is a key word in VB. Try changing it to something else like frm.

SCBWV 71 Junior Poster

Your code would probably be more efficient and more readable with a Select Case block instead of the IF, ElseIf.

Select Case dbltotalaverage
    Case 90 To 100
        txtgrade.Text = "A"
    Case 80 To 89
        txtgrade.Text = "B"
   Case 70 To 79
        txtgrade.Text = "C"
   Case 60 To 69
        txtgrade.Text = "D"
   Case Else
        txtgrade.Text = "F"
End Select
SCBWV 71 Junior Poster

Error 453 means the DLL function specified was not found within the DLL. Try making the Sub Public.

SCBWV 71 Junior Poster

Use RichTextBoxName.SaveFile(pathname) and RichTextBox.LoadFile pathname. The default file format is RTF.

SCBWV 71 Junior Poster

Use the StrConv function:

Text1.Text = StrConv(Text1.Text, vbProperCase)

vbProperCase converts the first letter of every word in string to uppercase.

Other constants are vbUpperCase, vbLowerCase, vbUnicode, and vbFromUnicode.

SCBWV 71 Junior Poster

Checkboxes can also be set programmatically - ListView1.Checkboxes = True/False

SCBWV 71 Junior Poster

That's because by the time Text2.Text = Text1.Text executes, Text1.Text has already been changed. Try:

Dim Txt as String
Txt = Text1.Text
Text1.Text = Text2.Text
Text2.Text = Txt

SCBWV 71 Junior Poster

Use a Label in front of each text box and in the Caption for the Label, use an & in front of the letter to define the shortcut key - &m in your example. Make sure the Label's TabIndex is one less than the TabIndex for its associated TexBox. That should do it.

SCBWV 71 Junior Poster

Post your declarations here so we can see what you're doing.

SCBWV 71 Junior Poster

Go to the Project menu and select Add Module. Open a New module and you will see it in the list (Module1).

SCBWV 71 Junior Poster

I put all my global declarations, constants and defined types in a module.

SCBWV 71 Junior Poster

There is no caption in the label to retrieve.

Comatose commented: Good Response! +10
SCBWV 71 Junior Poster

Why can't you just put centering code in the Form_Load event of the mdi child form? You know what window will be the parent, and it wouldn't matter is the parent is maximized or normal.

SCBWV 71 Junior Poster

You could use the multiple-document interface (MDI) in which the forms are a "child" of the "parent" main form, but MDI program can be a pain. Why can't you just use the main form's properties to decide where the other forms should appear? For example, in the Form_Load event of Checkout...

Top = Form1.Top 'add any offset you want
Left = Form1.Left 'again add the desired offset

SCBWV 71 Junior Poster

The Str function returns a leading space for the sign of number. Could that be messing you up? Sinec the leading space is there, you could use "R01" & str$(99)

SCBWV 71 Junior Poster

If you want to trap the Tab key in the KeyPress event, you have to disable to TabStop property in all other controls on the form, but you will have to handle moving the control focus yourself. Once the TabStop property is set to false, the Tab key will be trapped in the KeyPress event. Be sure to set the KeyPreview property on the form.

On Error Resume Next
For Each Control In Controls
Control.TabStop = False
Next

SCBWV 71 Junior Poster

Sounds to me like you want to sunchronize the toolbar on all the mdi forms. Try looping through the forms collection:

If you can identify each mdi form by name then you can use:

For Each frm In Forms
If frm.Name = "mdiform" Then
frm.Toolbar1.Buttons(5).Value = tbrPressed
End If
Next

If you can't specifically identify the mdi forms, use:

On Error Resume Next
For Each frm In Forms
frm.Toolbar1.Buttons(5).Value = tbrPressed
Next

I would also use Keys for your buttons, so if you change button positions in the toolbar, you won't have to redo a lot of code. You can assign each button a key. Then instead of referencing them by number you can reference them by name.

For example:
Toolbar1.Buttons(5) or Toolbar1.Buttons("Play")

SCBWV 71 Junior Poster

Just a guess... could it be the field is numeric, where your selection criteria (lblLECNUM ) is text (Caption property)?

SCBWV 71 Junior Poster

Check for both...

If InStr(Email$, "@") > 0 AND InStr(Email$, ".") > 0 Then
'Valid Email Format
else 'not valid
end if

pranavdv commented: helpful person upto the last query +1
SCBWV 71 Junior Poster

Well, you'll have to check for thsoe as well. But what's to prevent someone from entering "no@way.com" as a bogus address? There's really no way to validate legitimate addresses. I would check for the presence of an @ sign and a period in the input, and assume they typed a legitimate address.

SCBWV 71 Junior Poster

Why not use InStr?

If InStr(Email$, "@") > 0 Then 'Valid Email Format

If UCase$(Left$(Website$, 4))="WWW." then 'valid web format

If UCase$(Left$(Website$, 11))="HTTP://WWW." then 'valid web format

SCBWV 71 Junior Poster

Why not just copy the file PTSTEST over PTSPROD?

SCBWV 71 Junior Poster

Your code has many issues to be fixed... such as form placement, handling the backspace key, etc.

Anyway, I did what I could quickly. Try the attached.

You have to right click on the link and use "Save Target As" otherwise you will get a corrupt compressed file. Not sure why. Seems to be something with DaniWeb.

SCBWV 71 Junior Poster

Since it seems the Excel data is populating a text box control, why not use the Change event for the text box to trigger your code?

Qpido commented: Thanks +1
SCBWV 71 Junior Poster

App.Path is Read Only and is set to the path of the executable file. You shouldn't define this anyway, as a user may chose a different path when installing the program. You can use like App.Path$ & "\Data\MyFile.MDB" and your program will the data directory no matter when the user installed your program.

SCBWV 71 Junior Poster

Your syntax is wrong for the control array. frmsummary.lblfname(0) = frmWage.lblfirstname.Caption should be frmsummary.lblfname(0).caption = frmWage.lblfirstname.Caption

I don't think you're understanding the suggestions. If the labels are controls, you don't need to Dim strings.

In frmwage and your other form, text boxes should gather the user input. Then in the Form_Load event of the frmsummary form, you can use something like this:

Private Sub Form_Load()
for i = 0 to 9
frmsummary.lblfname(i).Caption = frmWage.lblfirstname(i).Caption
'use frmsummary.lblfname(i).Caption = frmWage.lblfirstname(i).Text for Text Boxes
next
end sub

Can you attach a zip file of your forms?

SCBWV 71 Junior Poster

The easiest way to make a control array is to create the first control, then copy and paste the others. The first time you paste the control, Visual Basic will ask you if you want to create a control array. Say yes. From then on, every copy you paste will be in the control array.

A couple points:

Control arrays require an index. For instead of lblfname.caption, it becomes lblfname(index).caption, where index is a number. The nice thing about control arrays is that they all share the same event procedures... click, change, etc. The Index argument of the procedure will tell you which control fired the event.

Control arrays default to an index of 0, although you can change it to 1. Therefore, the first control in the array will be 0; lblfname(0). So for your 10 labels it ranges from lblfname(0) to lblfname(9).

SCBWV 71 Junior Poster

In the Form_Load event of the summary form, load the captions from the other two forms.

It's probably NOT how I would populate data from one form to another, but if you insist on doing so with labels, I suggest making the labels a control array so you can populate them in a for / next loop:

for i - 0 to 9
frmsummary.label(i). caption = form1.label(i).caption
next

SCBWV 71 Junior Poster

Well, there's lots of ways to do this. For example, you could have labels for all 10 on the summary for and populate each individually from the first two forms. You could have the summary form contain a list control with columns that is populated from the other forms.

SCBWV 71 Junior Poster

You can use frmsummary.lblfname0.Caption = frmWage.lblfirstname.Caption or you can put the captions / text in public variables which are accessible to any form.

SCBWV 71 Junior Poster

The CoolBar is part of Microsoft Windows Common Controls-3. Using the Projects menu, select Components to bring up the Components dialog box. On the Controls Tab, check "Microsoft Windows Common Controls-3"

SCBWV 71 Junior Poster

The toolbar should be in a CoolBar. In the CoolBar Property Pages, on the Band tab, there's a settign for New Row. Add more then one Band and set the second Band to NewRow.