vb5prgrmr 143 Posting Virtuoso

Okay, this was the query I was pointing you too earlier...

S = "SELECT COUNT(*) AS THECOUNT FROM Table1 WHERE class = '" & Trim(Text1.Text) & "'"

You just need to adjust which table it points to (table1 vs. table2) and which field it points to.

Good Luck

vb5prgrmr 143 Posting Virtuoso
varname = Replace(varname, "'", "''")

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, this looks like it may help...

http://vbnet.mvps.org/index.html?code/comctl/lvledger.htm

Good Luck

vb5prgrmr 143 Posting Virtuoso

It might be they way you are using the select max. For future reference (without spaces) use the [ code ] [ / code ] tags to display your code (makes it easier to read).
Perhaps you should do a count or if the field is a unique id, do a top 1 desc to get the last id used.

Good Luck

vb5prgrmr 143 Posting Virtuoso
vb5prgrmr 143 Posting Virtuoso

Simple way is to add a module and declare the public variables there.

Good Luck

vb5prgrmr 143 Posting Virtuoso

How much are you going to pay if we code your solution for you?

How about you take a look at post #12 in this thread...

http://www.codeguru.com/forum/showthread.php?t=476345&highlight=ado+dao

and do some work yourself!

Good Luck

vb5prgrmr 143 Posting Virtuoso

Now, I know that does not solve your problem but you have the hints in the add new button on how to find out how many students are enrolled. If you need any more help just ask.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, looking at project now and I have some suggestions...

Under the add new button you should add a check to see if there is information to add...

You should also check to see if the class exists...

Private Sub cmdaddnew_Click()

On Error GoTo cmdaddnew_ClickError

Dim daoRs00 As DAO.Recordset, S As String

If Trim(Text1.Text) = "" Then
  MsgBox "Please Add Class Name", vbOKOnly + vbInformation, "Class Name"
  Text1.SetFocus
  Exit Sub
Else
  S = "SELECT COUNT(*) AS THECOUNT FROM Table1 WHERE class = '" & Text1.Text & "'"
  Set daoRs00 = db.OpenRecordset(S, dbOpenDynaset, dbConsistent, dbOptimistic)
  If daoRs00.RecordCount <> 0 And daoRs00.EOF = False And daoRs00.BOF = False Then
    
    'have a resultset
    If daoRs00.Fields("THECOUNT") > 0 Then
      
      'okay, if count is greater than zero then class already exists
      MsgBox "Class exists!", vbOKOnly + vbInformation, "Duplicate record"
      
      'close rs, exit
      daoRs00.Close
      Set daoRs00 = Nothing
      Exit Sub
      
    Else
      
      rs.AddNew
      rs("class") = Text1.Text
      rs.Update
      
    End If
    
  Else
    
    'if we are here for some reason then the query failed for some reason
    daoRs00.Close
    Set daoRs00 = Nothing
    
  End If
  
End If

Exit Sub
cmdaddnew_ClickError:

MsgBox "cmdaddnew_Click " & Err.Number & ":" & Err.Description

End Sub

Then when the form unloads, you need to take care of your objects...

Private Sub Form_Unload(Cancel As Integer)

On Error GoTo Form_UnloadError

rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

Exit Sub
Form_UnloadError:

MsgBox "Form_Unload " & Err.Number & ":" & Err.Description

End Sub

Oh yeah, as you can see in the code examples, …

vb5prgrmr 143 Posting Virtuoso
DTPicker1.Format = dtpCustom
DTPicker1.CustomFormat = "hh:mm:ss tt"
DTPicker1.Value = "10:55:23 AM"

Good Luck

limesight18 commented: thx +1
vb5prgrmr 143 Posting Virtuoso

Children,... children, (myself included) tempers,... tempers (not myself included as I'm kind of giggling at these latests posts).

jephthah,

Perhaps, just perhaps, you might be able to help Engineer.Saleh by giving them a clue as to what keywords you used to search the help files or the web. Just a small point in the right direction.

vb5prgrmr 143 Posting Virtuoso

If you are talking about the ADODC (ado Data control) and the MSFlexGrid or the MSHFlexGrid then yes you can populate either grid without the use of the control. However, the easiest way is to bind your datasource to the controls datasource property but you do not have to. You can populate these grids yourself but it requires more code.

Good Luck

vb5prgrmr 143 Posting Virtuoso

By roll, I take it you mean enrolled in such class whatever number it may be...

So, you have a TableOfClasses table and a StudentsTable table and you want to know how many students have been enrolled in whatever class. So lets add another table, TableEnrollment.

The fields of this table will be (in very simplistic terms)...

ForeignKeyToClassesTable
ForeignKeyToStudentsTable

Then with this information we can then do a simple count query against the EnrollmentTable...

strSQL = "SELECT COUNT(*) AS THECOUNT FROM tblEnrollment WHERE ForeignKeyToClassesTable = " & 10 'class # 10
....
CountOfStudents = adoRs.Fields("THECOUNT") 'this ='s the number of students already enrolled. Then if we did a +1 we would have the count of how many students are enrolled in this class now that we added this student.

Now that is only one way to accomplish this and depending upon your table structure we may be able figure out a different way of accomplishing what you need.

Good Luck

vb5prgrmr 143 Posting Virtuoso

A single project can contain up to 32,000 "identifiers" (any nonreserved keyword), which include, but are not limited to, forms, controls, modules, variables, constants, procedures, functions, and objects. Note that the actual number of identifiers is limited to available memory.

Good Luck

vb5prgrmr 143 Posting Virtuoso

remove the date part of my suggestion...

Good Luck

vb5prgrmr 143 Posting Virtuoso

from vb's help file...

Project Limitations


A single project can contain up to 32,000 "identifiers" (any nonreserved keyword), which include, but are not limited to, forms, controls, modules, variables, constants, procedures, functions, and objects. Note that the actual number of identifiers is limited to available memory.

Variable names in Visual Basic can be no longer than 255 characters, and the names of forms, controls, modules, and classes cannot be longer than 40 characters. Visual Basic imposes no limit on the actual number of distinct objects in a project.

So I don't think you should be worried yet...

However, I would suggest that you break up your code some and perhaps move some of your forms code to modules.

Good Luck

vb5prgrmr 143 Posting Virtuoso

I believe this should get you started...

DTPicker1.Format = dtpCustom
DTPicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss tt"

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well lets start with your declaration statement...

Dim car, color, door As String, cost, cost1, cost2, cost3 As Single

Just so you know, car, color, cost, cost1, cost2 are all varients while only door is a string and cost3 is a single.

Next off, since you are doing cost? = cost? + value and each of those cost's are declared within the click event, they will loose their value once the click event is exited.

Then, I'm not sure if you copied your code correctly but it looks like you have declares a sub proceedure within the click event proceedure....

The showcost sub should not be wrapped by the click event of the command button, it should be its own sub.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well, it really depends on exactly what you are doing...

If you have something like this...

Procedure01 calls procedure02
Procedure02 calls procedure03
03 calls 04
04 calls 05
....

Then what you are doing is building up the stack space and thus you can see the memory expand.

However if you do something like this...

01 calls 02 and 02 returns to 01 (then pop off the stack it comes)
01 calls 03 and ....

then your memory will fluxuate up and down but not too seriously unless you keep building things up in memory... Meaning if you have lets say a string varible declared in the general declaration section of the form and your sub/functions keep adding to it.

So when you say your private variables are not being cleared when a sub is done, it leads me to belive that these variables are in the general declaration section.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Kehar,

You failed to mention what kind of database. Access, MySQL, SQL, Progress, Alpha, Oracle, Fox Pro?

However, for most of those it is as simple as having a lookup table to populate your combo box and to change the table your queries look to. BUT, for some things like triggers, stored proceedures, and such, this will make your job a little harder as you will need to alter those to either accept a parameter or to look up in your lookup table to build their functionality.

So, in short, for us to help you better we will need to know what is your backend.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Use the data form wiard with all possible combinations of form types with each of the code/class/control options.

vb5prgrmr 143 Posting Virtuoso

Engineer is also a degree...

vb5prgrmr 143 Posting Virtuoso

jephthan,

I thought about flagging your post but then I thought I would share a story with you, but who knows, someone else might come along and flag it...

When I was working with a unnamed company, they hired a guy nearly strait out of college at nearly double the amount of pay I was recieving. No prob, he had all the right initials after his name but come to find out he could not program in VB or any of the C varients worth a lick. Not saying that he could not get the job done EVENTUALLY, but his experience was nearly null. It seems that his education was more in the theory of things than actual practice and there are a great many colleges/universities that continue to teach this way. So perhaps, Engineer.Saleh may have some of those initials and perhaps they were educated this way. Either way, who are you to say something about or comment about a persons moniker/handle?

Engineer.Saleh,

If you do a search at this site or google or yahoo with your keywords, you should find many examples in VB6 that for the most part should be able to be converted to VBA.

Good Luck

vb5prgrmr 143 Posting Virtuoso

The reason for the difference between the need for an API call and browse and add is the difference between a standard dll and an activex dll.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well for future reference...

The C#.NET forum on this site is...

http://www.daniweb.com/forums/forum61.html

and the VB.NET forum is...

http://www.daniweb.com/forums/forum58.html

and perhaps PMing a MOD might solve the other problem...

Glad you got it solved...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Wrong forum, you need the dot net forum...

vb5prgrmr 143 Posting Virtuoso

The replace function.

However, let me remind you that you should have started your own thread and if you wanted to reference this thread you could have copied the url and posted it with your post with words like, in reference to...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, did you move your project.dll into the same folder as your new project that wants to call it or did you move the project dll to the \windows\system32\ directory? Did you register the dll?

Good Luck

vb5prgrmr 143 Posting Virtuoso
vb5prgrmr 143 Posting Virtuoso

Then you should be able to use the click event of the combo box to query for the ID be it against the database, the text of the combo box (if you saved the ID with the text) or against its index (if you have some sort of way of doing that.

Good Luck

vb5prgrmr 143 Posting Virtuoso

33 pixels? Man your object is moving fast! Are you sure that the "play" area is a multiple of 33? Are you sure you are not talking twips?

Option Explicit
Dim GoingLeft As Boolean

Private Sub B3R1_Timer()

On Error GoTo B3R1_TimerError

If GoingLeft = True Then
  'make sure the left does not exceed the bounds of our background
  If (square3(0).Left - 33) < ImgBackground.Left Then 
    square3.Left = ImgBackground.Left 
    GoingLeft = False
  Else
    square3(0).left = square3(0).left - 33
  End If
Else
  'make sure bounds don't exceed
  If (square3(0).Left + square3(0).Width) > ImgBackground.Width Then
    square3(0).Left = ImgBackground.Width - square3(0).Width
    GoingLeft = True
  Else
    square3(0).left = square3(0).left - 33
 End If

Exit Sub
B3R1_TimerError:

MsgBox "B3R1_Timer " & Err.Number & ":" & Err.Description

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

I know other office applications have the ability to record macros and if power point does, then record a macro of what you want to do, view the code and for the most part move it over to VB6. If not, don't know what to tell you...

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well, unfortunatly Jupiter 2, elanch is using one of the .NET variants (2k2, 2k3, 2k5, 2k8, and soon 2k10).

elanch,

If I remember correctly, the vbproj file is an XML file and if I am correct you should be able to open it up with Notepad. The only one good thing that I can think of is that the error message has given you the place to look. Open up another *.vbproj file and the one giving you problems and see what is missing/wrong/etc...

Okay, just confirmed that it is an XML file (I have 2k8 Pro) and a blank form project looks like this...

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.21022</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{EFB72206-21FC-42D4-BC38-BB31BAE8FF2A}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <StartupObject>WindowsApplication1.My.MyApplication</StartupObject>
    <RootNamespace>WindowsApplication1</RootNamespace>
    <AssemblyName>WindowsApplication1</AssemblyName>
    <FileAlignment>512</FileAlignment>
    <MyType>WindowsForms</MyType>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <OptionExplicit>On</OptionExplicit>
    <OptionCompare>Binary</OptionCompare>
    <OptionStrict>Off</OptionStrict>
    <OptionInfer>On</OptionInfer>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>WindowsApplication1.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>WindowsApplication1.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Drawing" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Windows.Forms" />
    <Import Include="System.Linq" />
    <Import Include="System.Xml.Linq" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Form1.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Form1.Designer.vb">
      <DependentUpon>Form1.vb</DependentUpon>
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="My …
vb5prgrmr 143 Posting Virtuoso

Okay, several options here that I can think of but without further code I'm shooting in the dark but here is what I can guess from what I have read so far...

You have a table with sales reps names that has a unique ID.
The combo is populated with the sales reps names as pulled from database by some order but probably on the unique ID.

Problem at this point. While the unique ID is more than likely 1 based the combo box index is 0 based and if you could guarantee that reps would always never quit, retire, or die then all you would need is unique ID - 1 to get the sales rep name to display and inversly Index + 1 to set the sales rep. However, I doubt that you could gaurantee such a thing.

So now you want to display in the combo box the name of the rep that will be credited for the sale and you have the reps unique ID in the .SalesRep variable.

So, with this information you can...

Query the database for the reps name, then loop through the combo box looking for a match and once the match is found then use the index to display the name.

OR

You could create a type something like...

Private Type Rep
  RepName As String
  RepIndex As Integer
  RepUnique As Long
End Type
Dim Reps() as Rep

and when you populate the …

vb5prgrmr 143 Posting Virtuoso

To begin with VBasic 10 would be VB.NET...
Second, Jupiter 2's reply is not entirely correct...

There are out there programs that "say" they can reverse engineer programs, i.e. decompile programs and while they are capable of doing such things, the result is less than readable. For each sub/function/property/event etc. there will be an identifier something like A123_57(a_,B_,C_) A1 and while you will be able to read basic logic structures (If, Do, For, Select) the variables will be just as unreadable as the proceedures.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Select * From YourTable Where UniqueID = 93

Although, I'm willing to bet the answer to your question is not going to be that easy. For us to help you better we could use some more information like some sample data, the structure of you table, is there any possible filtering criteria, and just exactly what you are after because there may be more than one way to solve your problem.

Good Luck

vb5prgrmr 143 Posting Virtuoso

So you say it runs on your computer but not on another. Did you create an install package with the Package and Deployment Wizard (A.K.A. PDW) or use Inno to do so and if you did then did you install in on the other computer?

vb5prgrmr 143 Posting Virtuoso

Where is .SalesRep declared and where is its parents with statement?

Good Luck

vb5prgrmr 143 Posting Virtuoso

But this is what I am getting at right here from your first post...

Private Sub Command3_Click()
>>>Set CON = New ADODB.Connection
>>>If CON.state = adStateOpen Then

At this point you have not opened the connection object. You have only declared it and in your next line you test before it is open. That is what I was getting at.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, so your doing this programming inside of excel? Then you need a vba forum and not a vb6 forum.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Then, (If I remember correctly) you need to prefix tablename (Table1) with the database name and for access that would be the path to the database. So, what you do is open the database that you want to move the records from and do something like...

INSERT INTO Table1 ( vText ) IN 'c:\z\test2.mdb'
SELECT Table1.vText
FROM Table1;

Okay, so what the above does is move the data from Table1 in Test1.mdb to Table1 in Test2.mdb...

NOTE: For future reference, using the Microsoft Access Query builder and design window is a very smart thing to do no matter what database or DBMS system you are working with. Meaning, if you are working with SQL server, MySQL, Progress, Oracle, etc. and you need to create a query of some sort, create a database with the appropriate tables that you want to work with and use access to build your query strings for you.

Now back to our regular scheduled program...

So what you would need to do then is something like...

strSQL = "INSERT INTO Table1(LineNumber, JobName, Batch, Coder, DocDate, 
DocChar) IN 'c:\z\test2.mdb' SELECT Table1.LineNumber, Table1.JobName, Table1.Batch, Table1.Coder, Table1.DocDate, Table1.DocChar FROM Table1"

And just to make sure that you are reading the above correctly. The above says that I have a database open and I want to insert from the currently open database to my main database named test2.

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you are talking about where you have the color tags that show up as text then I would say you have to open the connection before you can test it. From what I see you have only declared the variable con as a New ADODB.Connection but have not acutally opened it.

Basically you have done something like this...

Dim I as Integer
If I = 2 Then 'where I will only equal zero because you have not yet given it a value

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, the closest you are going to get as far as I know is...

Dim aTemp(0 to 1, 0 to 1) As Integer

But then you would have to do...

aTemp(0,0) = 1
aTemp(1,0) = 2
aTemp(0,1) = 3
aTemp(1,1) = 4

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, As long as none of the fields that you mention are of an autonumber field you can do something like...

strSQL = "INSERT INTO Table1(LineNumber, JobName, Batch, Coder, DocDate, DocChar) SELECT Table2.LineNumber, Table2.JobName, Table2.Batch, Table2.Coder, Table2.DocDate, Table2.DocChar FROM Table2"

Then execute via command object and what this will do is take the information from Table2 and append it into Table1.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Or there is the formatnumber function...

?formatnumber(1/ 2946.33,8)
0.00033941

Where the "8" after the comma tells the function how many places after the decimal you want.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Is the excel sheet used for input? Meaning does the excel sheet contain the names of the books and the prices? If so then it is not one time.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay,... You say you have a bunch of txt files and you want to go through these text files and extract specific data from each file. Now, from what you have told us so far in this thread is that these text files can come in two formats. The first format is in your first post and the second format is in your second post (#3 above).

Now, here are some questions for you.

1.) Are these text files in a single directory?
2.) If they are in a single directory, do you want your program to read these files in one after another automatically or do you want to select one file at a time.

If one file at a time then search the web for Common Dialog Control ShowOpen to find some example on how to use the control. The control comes with VB and you already have it. Right Click on your toolbox>components>select Microsoft Common Dialog control.

Now, if your files are in one directory and you want to have your program read one file after another then search the web for SHBrowserForFolder API VB6 to find examples.

Then you will need to know about any one of the following to be able to make a list of these files. The (Dir function), (FSO (File System Object)), (DriveListBox, DirListBox, FileListBox), (FindFirstFile, FindNextFile API's). (NOTE: Various Technologies grouped by parens().)

Okay, so now you have the decision of one file at …

vb5prgrmr 143 Posting Virtuoso

Sounds like you need speed throughout. So I would suggest C, C+, C++, and also would suggest anything that uses a lot of overhead in the way of libraries you should stay away from and this means .NET. You can however have all your inportant code that needs the speed in a C/C+/C++ exe/dll and use another language like VB or .NET as the user interface (i.e. start/stop button) but if you are going to put so much into a C language then you might want to continue to use a C language like VC++.

Good Luck

vb5prgrmr 143 Posting Virtuoso

You might get away with

Printer.Orientation = vbPRORLandscape

Or via the use of the common dialog control but if not you will have to go around the hard way with the SetPrinter API.

Good Luck

vb5prgrmr 143 Posting Virtuoso

GoTo http://www.microsoft.com then there is a navigation and the second from the right is Support. Click that and when the list appears click on MSDN. However, a lot of documentation is geared towards .NET so when you search you will need to add either VB6 or Visual Basic 6.0 to your queries.

Good Luck