vb5prgrmr 143 Posting Virtuoso

As a simple example...

Option Explicit

Dim SelectedListBoxItem As Integer

Private Sub Command1_Click()
MsgBox List1.List(SelectedListBoxItem)
End Sub

Private Sub Form_Load()
Dim ForLoopCounter As Integer
For ForLoopCounter = 1 To 10
  List1.AddItem CStr(ForLoopCounter)
Next ForLoopCounter
End Sub

Private Sub List1_Click()
SelectedListBoxItem = List1.ListIndex
End Sub

Now, the above example is for a string but you say your field is a number and I also see that your number is wrapped by single ticks ' . Well those denote that what you are passing is a string and not a number, hence the data type mismatch error.

Good Luck

vb5prgrmr 143 Posting Virtuoso

I believe I responded to your PM with the answer. If so please post your final answer here and mark this thread as solved.

vb5prgrmr 143 Posting Virtuoso

Is the other program that you want to add to your package, yours?

If yes, then you will have to modify the setup exe project once again to add the progress bar and you will have to delve deeper into the setup package functions. You will need to somehow return the count of how many items are in the cab to be added to the other project. With this value you can set the max and the min at one. Then as each item is unpacked/copied/registered/etc. you would increase the value by 1 (.value = .value + 1).

Good Luck

vb5prgrmr 143 Posting Virtuoso

lpOperation
Address of a null-terminated string that specifies the operation to perform. The following operation strings are valid: "open" The function opens the file specified by the lpFile parameter. The file can be an executable file or a document file. It can also be a folder.
"print" The function prints the file specified by lpFile. The file should be a document file. If the file is an executable file, the function opens the file, as if "open" had been specified.
"explore" The function explores the folder specified by lpFile.

This parameter can be NULL. In that case, the function opens the file specified by lpFile.

lRet = ShellExecute(vbNull, "", strProgram, "", "", SW_SHOWNORMAL)
lRet = ShellExecute(vbNull, "open", strProgram, "", "", SW_SHOWNORMAL)

Since you are supplying a null string which is different than a null, it would be just easier to add the keyword for the function, "open".

vb5prgrmr 143 Posting Virtuoso

Thanks for replying vb5prgrmr

Can you explain a couple lines to me?
Why do I need to do that? And what are those two supposed to do?

ForLoopCounter As Integer, UpperBoundOfArray As Integer

You forgot the Dim which means Dimension e.g. your telling the complier to dimension/(reserved space in memory for this variable that will need x size). The x size is provided by the As VariableType, integer, byte, long, double, string, varient, etc.

Of which, you should always declare your variable and to force the environment (ide) to force you to do such a thing goto the ide's menu > tools > options and on the editor tab check the box next to where it says "Require Variable Declaration". Then in all future projects you will see Option Explicit at the top of each form and module.

I understand what the code is trying to do here, but I dont think I understand why you used those specific codes
So what does the part I highlighted in red do?

If Trim(strUsername) = Trim(ArrNames(ForLoopCounter, 0)) Then
    FoundName = True

The trim function removes extraneous spaces from a string because "this string" is not equal to " this string " because of the spaces.

I get the assigning of values here, but what does this mean?

UpperBoundOfArray = UBound(ArrNames)

I see someone has explained this already

And im not familiar with the "Next" syntax either

Next ForLoopCounter

In vb's help, on the index tab, type in "for keyword". …

vb5prgrmr 143 Posting Virtuoso

Unlikely you will find such an animal, but you could check ebay or various search engines (yahoo, google) or perhaps your local used book store.

Good Luck

vb5prgrmr 143 Posting Virtuoso

systemautorizin,

Nice little program but the OP (tripes) asked how to break down a selected color into the rgb triplet values. What tripes did not tell us is how they are getting those value and off the top of my head I can think of a couple of ways. GetPixel API, Point, and the common dialog show color method. Each of these methods returns a long value and the following shows how to break down that long into each of the rgb triplet values.

Dim MyColor As Long, R As Integer, G As Integer, B As Integer, Temp As Integer
MyColor = RGB(124, 45, 36)

Temp = MyColor Mod 65536
MyColor = MyColor - Temp
B = MyColor / 65536
MyColor = Temp
Temp = MyColor Mod 256
MyColor = MyColor - Temp
G = MyColor / 256
R = Temp
Debug.Print R, G, B

Good Luck

vb5prgrmr 143 Posting Virtuoso

First off, in the future it would be a good idea to also post the err.number and the err.description.

Now, if your err.number is 5 and your description is Invalid proceedure call or arguement then...

The intrinsic shell function built into vb is not used to open data files. It's main purpose is to open exe's. What you need to do is checkout the ShellExecute API.

Good Luck

vb5prgrmr 143 Posting Virtuoso

First off, modifying the setup package is a tricy thing to do. I hope you have backed those files up prior to attempting to make any changes.

Now as for running two setup programs, you will need to search for Shell and Wait on the net to find code that will launch a process and wait on it to complete and it is this code you will have to add to your setup project after the code that has extracted all the files from the cab.

Then when using the PDW, you would include the other setup files in your cab.

Good Luck

vb5prgrmr 143 Posting Virtuoso
Dim C As Control
For Each C In Me.Controls
  If C Is TextBox Then
    If Trim(C.Text) = "" Then
      C.SetFocus
      msgbox "message"
      Exit For
  ElseIf C Is ComboBox Then
    If Trim(C.Text) = "" Then
      C.SetFocus
      Exit For
    End If
  End If
Next C

Or...

If C Is TextBox Or C Is ComboBox Then

As you have done

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well, if it is being opened over a network it will take time. You will need to check your object to see if you were successful, or you could copy the file locally and then open the file, do your thing, and then copy it back.

Good Luck

vb5prgrmr 143 Posting Virtuoso

You need to loop through your array...

Dim FoundPass As Boolean, FoundName As Boolean, ForLoopCounter As Integer, UpperBoundOfArray As Integer
UpperBoundOfArray = UBound(ArrNames)
For ForLoopCounter = 0 To UpperBoundOfArray
  If Trim(strUsername) = Trim(ArrNames(ForLoopCounter, 0)) Then
    FoundName = True
    If Trim(strPassWord) = Trim(ArrNames(ForLoopCounter, 1)) Then
      FoundPass = True
      Exit For
    End If
  End If
Next ForLoopCounter
If FoundName = True And FoundPass = True Then
  'validation successful for both
Else
  'something missing
  If FoundName = False Then
    'msgbox...
  ElseIf FoundPass = False Then
    'msgbox...
  End If
End If

Now, while I check for both, you could break the loop up and the following if to put each part in the validate event for each control, or as I have tried to show you could put this under the command button's click event.

Good Luck

vb5prgrmr 143 Posting Virtuoso
vb5prgrmr 143 Posting Virtuoso

Well not sure how to do what you are wanting but the intrinsic date and time functions can change the systems date and time. Start a new project and add the code and run.

Option Explicit

Private Sub Form_Load()
Debug.Print Date
Debug.Print Time

Date = DateAdd("d", 1, Date)
Time = DateAdd("n", 1, Time)

Debug.Print Date
Debug.Print Time

Date = DateAdd("d", -1, Date)
Time = DateAdd("n", -1, Time)

Debug.Print Date
Debug.Print Time
End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

I would believe that anyone here would be willing to discuss VB. However, this is the VB "classic" forum for versions 4/5/6. If you have VB.NET version 2k2, 2k3, 2k5, or 2k8 you may want to ask your questions in the .NET forum.

Good Luck

vb5prgrmr 143 Posting Virtuoso

To begin with, when you say reports are you saying crystal reports or are you refering to some sort of bound/unbound data grid control or some other control? My guess was that you were talking about a bound control that needed to be refreshed. If this is wrong, then please add a little more information in what you mean by reports. BTW, if it is crystal reports then close it and reopen it.

Good Luck

vb5prgrmr 143 Posting Virtuoso

http://www.tek-tips.com
http://www.xtremevbtalk.com
but when it comes to the busiest sites
http://www.vbforums.com
http://www.dreamincode.net
Altho, the last one, and this just seems to me or is of my opinion that the mods look for posts without code and reply with a boilerplate, cut and paste statement asking for your code or portion thereof.

Then of course you have found this site

Good Luck

vb5prgrmr 143 Posting Virtuoso

To address controls in another form you need to add the form name...

Form1.Text1.Text

Good Luck

vb5prgrmr 143 Posting Virtuoso

Refresh/Requery

vb5prgrmr 143 Posting Virtuoso

ActiveX

vb5prgrmr 143 Posting Virtuoso

If you want to use SQL "Server" as you back end for a VB6 "Client" then....

You need to install the server

As for connection strings

http://www.connectionstrings.com/

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you open up Volume Control and play with this example program...

http://www.thescarms.com/VBasic/volumecd.aspx

you will see it adjusts the volume contol which is the system sound and not just the speaker volume control. However, if user right clicks on the volume control and clicks mute no matter what you do there will be no sound.

Now as for making a beep and a message box appear, this is once again dependant upon if the user has done one of two things. Have they disabled sound by click on the mute box? Have they gone to system sounds and set their system sounds to none? Because the standard vb msgbox should cause a sound when it displays but if the sound is muted or if the user has set their system sounds schemes to none, then you will not hear a beep.

To set system mute see these examples...

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_10167931.html

Now you have the information to make sure the system sound is not muted, and you can set the volume of the system (and others if you explore enough). Now to get around the user not having a sound scheme see this...

http://www.codeproject.com/KB/audio-video/soundalerts.aspx

or as the auther advises you can use sndPlaySound asynchronously right before you display your message box

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well, I don't know what to tell you then. Last guess is, is it declared properly?

vb5prgrmr 143 Posting Virtuoso

Set the computer up so its default printer is pointed to the printer you want.

Good Luck

vb5prgrmr 143 Posting Virtuoso

You will need to change the volume via the volume control through the system and you can do that via VB6 by starting off with the mixerSetControlDetails API. You can look this up in the VB help files and at the bottom of the page take a look at Audio Mixer Functions as you will need other API's to open/retrieve a handle to the mixer.

Good Luck

vb5prgrmr 143 Posting Virtuoso

see this

http://www.vb6.us/tutorials/indepth-vb6-listbox-tutorial

and check out the demos

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, in your else (CD Details) your missing the .text from your text box declaration and this should not be a problem but just in case.

I also see that you are not placing a space between your like's and the single tick Like' and once again this should not be a problem but I thought I would mention it.

Then I see you are using the percent character % as your wild card character and from my Access documentation (2k) I do not see it in the list of usable wild cards. If you are using Access, check its help file to see what wild card are available. (Same if you are using any other DBMS.

Good Luck

vb5prgrmr 143 Posting Virtuoso

To help us help you... we need a little more information. Are you using ADO, DAO, or RDO?

vb5prgrmr 143 Posting Virtuoso

Okay, did you open the database, a connection to the database?

vb5prgrmr 143 Posting Virtuoso

There is another way depending upon what version of VB you have.

Start new standard exe project
Goto vb's ide menu Add-Ins > select add-in manager.
Look for VB 6 Data Form Wizard, highlight > Look at frame in bottom right corner with caption Load Behavior > select Loaded/Unloaded so check mark displays in check box. > OK
VB IDE Menu Add-Ins > Data Form Wizard
Run through wizard selecting your access database via browse button on screen 3.
On next form enter the name of the form you want, the style, and the type. I would suggest to start off with the ADO Code unless this is the first time you have ever played with VB.

Actually I would suggest that you use each option with each type and save that as a test project for reference. Then you will have it for reference.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Where or what is the problem? Your code looks like it should work even if I have a few sugestions, but what I have in the way of suggestions may not help you, so please describe what kind of problem you are having or where your error is occuring.

Thanks

vb5prgrmr 143 Posting Virtuoso

perhaps this web site might help you with your connection string

http://www.connectionstrings.com/

if not, i am betting a google/yahoo search will return many vb examples

Good Luck

vb5prgrmr 143 Posting Virtuoso

MDI...

New Project > Menu Item Project > Add Form > MDI > Change Form1's Property MDI Child = True
Menu Item Project > Properties > Start up Object > MDIForm1 > OK
Double click MDIForm1 to get to its Form Load() Event
Add

Load Form1
Form1.WindowState = vbMaximized
Form1.Visable = True

Run and minimized child form

Good Luck

vb5prgrmr 143 Posting Virtuoso

Last time i used a stream object was with 2.5 (Microsoft ActiveX Data Objects 2.5).

Dim A As ADODB.Stream
Set A = New ADODB.Stream

'open the adodb filestream and save the file locally so we can check its file size then close the adodb filestream object
A.Type = adTypeBinary
A.Open
A.Write XMLHTTPOBJECT.responseBody
A.SaveToFile App.Path & "\temp.jpg", adSaveCreateOverWrite
A.Close
Set A = Nothing

and if you can't tell I used it with XML 3.0 to save a file to disk from the web.

How you want to use it may require a new thread.

Good Luck

vb5prgrmr 143 Posting Virtuoso
Option Explicit

Dim NumberOfCanidates As Integer
Dim CanidateNames() As String
Dim CanidateVotes() As Integer

Private Sub Command1_Click()
If Trim(Text1.Text) <> vbNullString Then
  NumberOfCanidates = NumberOfCanidates + 1
  ReDim Preserve CanidateNames(1 To NumberOfCanidates) As String
  ReDim Preserve CanidateVotes(1 To NumberOfCanidates) As Integer
  CanidateNames(NumberOfCanidates) = Text1.Text
  Combo1.AddItem Text1.Text
End If
End Sub

Private Sub Command2_Click()
Dim ForLoopCounter As Integer
For ForLoopCounter = 1 To NumberOfCanidates
  If CanidateNames(ForLoopCounter) = Combo1.Text Then
    CanidateVotes(ForLoopCounter) = CanidateVotes(ForLoopCounter) + 1
    Exit For
  End If
Next ForLoopCounter
End Sub

Command1 adds canidates to the array from values entered into text1.
command2 finds which canidate was selected from the combo box and increments his/hers vote by one.

Very simple example but should get you started.

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you are quering a text field then you need to encompass what you are quering against/for with single ticks '

squery = "Select * from tblStation where Station like [B]'[/B]" & txtStation.Text & "[B]'[/B]"

if number then you don't need...

squery = "Select * from tblStation where Station like " & txtStation.Text & ""

Good Luck

vb5prgrmr 143 Posting Virtuoso
sql = "select * from " & Combo2.Text & "'"

You don't need tick on the end.

Good Luck

PinoyDev commented: Very Helpful +1
vb5prgrmr 143 Posting Virtuoso

Okay, now that, that is over...

Did you change your API to what was suggested and your type as noted above? If so, are you still having problems with the right/bottom areas of rect region?

HINT:
Right = left + width
Bottom = Top + Height

Still problems?

Did you change your scalemode from twips to pixels? (Or you should be able to find calculation code that will convert twips to pixels if you need it).

Good Luck

vb5prgrmr 143 Posting Virtuoso

g_8306 @ vbforums? See replies there

vb5prgrmr 143 Posting Virtuoso

I'm thinking FORM and not forum and the OP is using Access 2k3 and the forms the Access environment provids. It also seems that the form they are using is not bound by query or control but beyond that I am clueless as all others...

vb5prgrmr 143 Posting Virtuoso

well left, top, right are functions and properties in vb and perhaps you should prefix them with My or MyFormsLeft etc.

then in form load... me.visible=true, prior to your setting the cursor

Good Luck

vb5prgrmr 143 Posting Virtuoso

Unless I am misunderstanding you, all of your fields are in the details table, No need for a join.

Good Luck

vb5prgrmr 143 Posting Virtuoso

An example of psudo code about the game hangman
http://www.tek-tips.com/viewthread.cfm?qid=1534972&page=1

vb5prgrmr 143 Posting Virtuoso

Well, I can tell you why. You are going from the first character to the last character and not stopping on either yes or no, so what you are seeing as the loop ends, it the last test on the last letter.

Look up InStr and the Do Loop structure.

It also looks like you are still in the testing stage. Do you know what psuedo code is? If you do, please post your general logic and a description of your design.

Good Luck

vb5prgrmr 143 Posting Virtuoso
Option Explicit

Private Sub Form_Load()
Text1.Text = "This is a test. This is only a test."
End Sub

Private Sub Command1_Click()
Randomize
Dim ForLoopCounter As Integer, TextLength As Integer, TempInt As Integer
TextLength = Len(Text1.Text)
For ForLoopCounter = 1 To TextLength
  If Mid(Text1.Text, ForLoopCounter, 1) <> " " Then
    TempInt = (Rnd * 1) + 1
    If TempInt > 1 Then
      ChangeCase ForLoopCounter, True, TextLength
    Else
      ChangeCase ForLoopCounter, False, TextLength
    End If
  End If
Next ForLoopCounter
End Sub

Private Sub ChangeCase(Position As Integer, UpperCase As Boolean, StringLength As Integer)
If Position = 1 Then
  If UpperCase = True Then
    Text1.Text = UCase(Left(Text1.Text, 1)) & Mid(Text1.Text, 2)
  Else
    Text1.Text = LCase(Left(Text1.Text, 1)) & Mid(Text1.Text, 2)
  End If
ElseIf Position = StringLength Then
  If UpperCase = True Then
    Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & UCase(Right(Text1.Text, 1))
  Else
    Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & LCase(Right(Text1.Text, 1))
  End If
Else
  If UpperCase = True Then
    Text1.Text = Left(Text1.Text, (Position - 1)) & UCase(Mid(Text1.Text, Position, 1)) & Mid(Text1.Text, (Position + 1))
  Else
    Text1.Text = Left(Text1.Text, (Position - 1)) & LCase(Mid(Text1.Text, Position, 1)) & Mid(Text1.Text, (Position + 1))
  End If
End If
End Sub
vb5prgrmr 143 Posting Virtuoso

check your personal messages

vb5prgrmr 143 Posting Virtuoso

okay, from the help files

Recordset Property (ADO Data Control)
      

Returns or sets a reference to the underlying ADO Recordset object.

Syntax

object.Recordset [= recordset]

The Recordset property syntax has these parts:

Part Description 
object Anobject expression that evaluates to an object in the Applies To list. 
recordset A recordset object. 


Remarks

Using the Recordset property, you can use the methods, properties, and events of the ADOADODB.Recordset Object.

You must use the Set statement with the Recordset property, as shown below:

Dim rsNwind As New ADODB.Recordset
' Code to open the ADO Recordset object not shown here.
Set ADODC1.Recordset = rsNwind

If you intend to program the events of the Recordset object, declare an object variable using the WithEvents keyword, as shown below.

Option Explicit
Dim WithEvents rsNames As ADODB.Recordset

Private Sub Form_Load()
   Set rsNames = New ADODB.Recordset
   ' Code to create recordset not shown.
   rsNames.MoveFirst ' Move to the beginning of the recordset.

   Set ADODC1.Recordset = rsNames

   With Text1
      Set .DataSource = ADODC1
      .DataField = "Name"
   End With
End Sub

Private Sub rsNames_FieldChangeComplete(ByVal cFields As Long, _
ByVal Fields As Variant, ByVal pError As ADODB.Error, adStatus As _
ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
   Debug.Print "New Name", pRecordset!Name
End Sub

and

Recordset Object (ADO)
               

A Recordset object represents the entire set of records from a base table or the results of an executed command. At any time, the Recordset object refers to only a single record within the set as the current record.





Remarks

You use Recordset objects …
vb5prgrmr 143 Posting Virtuoso

Okay, to print it out by a single field in a specific order, you cannot have another field "requisition_no" ordered first because as you have it now...

req#  ser#
1        5
1        4
1        3
1        2
1        1
2        3
2        2
2        1
...

is the way it is ordered presently. Either switch them around or to print them out use another query.

NOTE: if you order them both DESC (descending) then your recordset will be ordered by most recent first (that is if you have an incrementing req# and ser#).

Good Luck

vb5prgrmr 143 Posting Virtuoso

so then you have it working?

vb5prgrmr 143 Posting Virtuoso
"ORDER BY MaterialRequisitionOrder.serialno DESC;"