hkdani 39 Posting Pro in Training

my problem is that I am having problems with binding access 2007 table to an ADO and for that matter, a combo box.

Don't use Microsoft.Jet.OLEDB.4.0 for provider.
You need to use the "Microsoft.ACE.OLEDB.12.0"

The easiest way is to setup a Data Link or a Data Provider.

hkdani 39 Posting Pro in Training

Use text input to determine which value or values found in a database recordset to automatically display.

So, you only have what looks like three possible outcomes: (1) one value, (2) multiple values, or (3) no values.

For which outcome do you wish to program? You need to break down the problem into small pieces. And solve the problem piece by piece.

Use the Change Event of the TextBox to select a value to use for your search.

Private Sub Text1_Change()
     Static blnEntered as Boolean 
     if blnEntered then GoTo ResetFlag
     Dim strCurrentText as String
     Dim strDBMatch as string
     Dim intLength as Integer
     strCurrentText = Text1.Text
     intLength = Len(strCurrentText)
     ' Open your recordset
     rst.MoveFirst
     while Not rst.EOF 
         strDBMatch = rst.Fields("MyField") 
         if (len(strDBMatch) >= intLength) then
              if (strCurrentText = left(strDBMatch, intLength)) then
                    Text1.Text = strDBMatch
                    blnEntered = True
              End if
         End if  
     Wend
     Exit Sub
ResetFlag:
     blnEntered = False
End Sub

I haven't tried this. Don't know if it will work. But you see the basic solution. Test the input against the database. Replace the value of the Text box with the value of the field in the recordset. And there's a GoTo. Good Grief!
There are a few problems in the While Loop. But you'll have to fix those. And if you want to search and list Multiple Values. You'll have to figure that out.

I have no idea why a teacher would unleash such a problem on a beginning programmer. He ought to be …

hkdani 39 Posting Pro in Training
  1. Well, you have to load the values for the list you are using a reference somewhere. You have to do this first.
  2. Then you have to use the text entry value to search through the loaded values.
Private Sub LoadArray()
     Dim strArray(25) as string 
     dim i as integer
     rst.MoveFirst
     for i = 0 to 25
          If not rst.EOF then
                strArray(i) = rst.Fields("ListName")
          Else
               exit sub
          End if
          rst.MoveNext
     next i
End Sub

Private Sub ExpandTextBox (ByVal CurrentEntry as String)
     ' Write code here to search through array using the current entry in the text box
     ' Expand the value in the textbox, if you have a search match of the letters to the corresponding amount of letters in the pre-loaded values.
End Sub
hkdani 39 Posting Pro in Training

Use the ItemClick event

Please, use code tags when posting your code: "code=vb6" "/code" but use brackets [] instead of quotation marks.

Click on the Code Tag Icon next to quote tag in the editor. It should paste the appropriate code tags into the editor automatically.

Private Sub ListView1_ItemClick(ByVal Item As ComctlLib.ListItem)
    Dim strItem As String
    strItem = Item
    Debug.Print Item
    ' Use strItem as the basis for SQL query
    ' Write the code
End Sub
hkdani 39 Posting Pro in Training

rs.Open "Select * from tblpos where category like '" & cbocategory.Text & "' and date between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "';", cn, adOpenKeyset, adLockOptimistic

This is what I meant: Instead of using "' use """. You need to start using a SQL Designer and testing your sequel statements before using them. The data environment with VB6 has one and Microsoft Access has its own sequel designer. But you should make sure that your sequel statements actually work before plugging them into your code.

Also, I can't really tell where the ELSE statement where the error occurs. You have line numbers on your post for your code. Mention the specific line number. It's helpful to add error checking code that includes at least the following:

  1. err.Source 'The error source
  2. err.Description 'The error description
  3. err.Number 'The error number

If you could provide these three things it would be easier to pinpoint the error.

rs.Open "Select * from tblpos where category like '" & cbocategory.Text & "' and date between """ & DTPicker1.Value & """ and """ & DTPicker2.Value & """;", cn, adOpenKeyset, adLockOptimistic
hkdani 39 Posting Pro in Training

That error just means that the Type WAVEHDR has not been previously defined or declared in the VB6 environment by the user.

WAVEHDR could be anything the user wants to declare it as, for example:

Private Type WAVEHDR
     intWaveLength as Integer
     dtChanged as Date
     dtCreated as Date
     WaveName as String
End Type
hkdani 39 Posting Pro in Training

how to create a text file and to write into it

I've worked with these before. And from looking at the specs of your scanner all you have to do is scan the barcode, the barcode scanner will decode the symbols and translate them into ASCII characters that can be read as text.

To make it easy on yourself. Drag a Text Box Control onto your form. Make sure the MultiLine property is set to True.

Start your program. Make sure the focus is on the Text Box by clicking your mouse on the text box.

Scan a bar code. Press the button and then you should see the text appear in the text box.

You shouldn't have to worry about special drivers. Your scanner acts like a USB keyboard input and should be detected as such. And since it acts like a keyboard, you should receive input similar to that you would receive from typing on your keyboard.

For coding purposes. You should have a careful look at your documentation. Oftentimes a scanner will send a special character that you can check and look for in your program to verify that you are receiving a bar code scan and not just regular input from the keyboard. You can then write code to set the focus to a text box or read the input into a string variable which you can process later.

And just as there are special characters at the start of …

hkdani 39 Posting Pro in Training

That should get you started. Use your documentation to find out which methods to use. I hope you have not waited till the last minute!

Public Class frmScoreBoard

    Private Sub bnEnterScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnEnterScore.Click
        Dim strScore As String
        Dim intTotal As Integer, intCounter As Integer

        strScore = InputBox("Enter Score", "Score!", "0")
        If IsNumeric(strScore) Then
            ' Add Code Here add item to the list box. Use your help file
            ' under the Index Tab input InputBox to find help on how to use the function.
        ElseIf (strScore = ' ? ' Check documentation for InputBox to see what the return value will be if the user presses the cancel button.
            For intCounter = 0 To lstResults.Items.Count - 1
                ' intTotal =  ' Add code to accumulate the total for the score
            Next
            ' Enter Total 
            ' Use methods from the list box control to add the item to the list.
        Else
            Exit Sub
        End If
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
        ' Use methods from the list box control to clear the list.
    End Sub

    Private Sub frmScoreBoard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
hkdani 39 Posting Pro in Training

You're in the wrong forum. You are using VB.NET. This is VB4/5/6
Post over there and someone, more than likely, will help you.

[Public Class footballfever

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuexit.Click
Close()
End Sub

Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuclear.Click
lstScoreBox.Items.Clear()
lblfinalscore.Visible = False
btnEnterScore.Enabled = True



End Sub

Private Sub btnEnterScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterScore.Click
Dim strscore As String
Dim decscore As Decimal
Dim decfinalscore As Decimal = 0D
Dim strinputboxmessage As String = "enter the score for game #"
Dim strinputboxheading As String = "football score"
Dim strnormalboxmessage As String = "enter the score for game #"
Dim strnonnumericerror As String = " Error - enter a number for the score #"
Dim strnegativeerror As String = "Error please enter a positive number for score #"
Dim dectotalscore As Decimal
Dim strcancelbuttonclicked As String = ""
Dim intmaxnumberofentries As Integer = 10
Dim intnumberofenteries As Integer = 1

strscore = InputBox(strinputboxmessage & intnumberofenteries, _
strinputboxheading, " ")
Do
Do Until intnumberofenteries > intmaxnumberofentries _
Or strscore = strcancelbuttonclicked

If IsNumeric(strscore) Then
decfinalscore = Convert.ToDecimal(strscore)
If decscore > 0 Then
Me.lstScoreBox.Items.Add(decscore)
decfinalscore += decscore
intnumberofenteries += 1
strinputboxmessage = strnormalboxmessage
Else
strinputboxmessage = strnegativeerror


End If

Else
strinputboxmessage = strnonnumericerror
End If

If intnumberofenteries <= intmaxnumberofentries Then
strscore = InputBox(strinputboxmessage & intnumberofenteries, _
strinputboxheading, " …
hkdani 39 Posting Pro in Training

You have a MultiSelect property on the list box that should handle what you want to do.

There are 3 properties. You'll have to choose the appropriate value.

Hint: Only one will work for your desired outcome. And you'll have to change the logic on the if / end if. If you find one and then exit the sub, then you will not find the other.

Private Sub Command1_Click()
     Dim i As Integer
     For i = 0 To List1.ListCount - 1
          List1.ListIndex = i
          If List1.List(i) = Text1.Text Then
               MsgBox "Your item has been found." & i, vbInformation + vbOKOnly, "Found"
               Exit Sub
          End If
     Next i
     MsgBox "Not found", vbExclamation + vbOKOnly, "Not found"
End Sub
hkdani 39 Posting Pro in Training

It's called being an idiot.

Idiot is an inaccurate statement and unacceptable for use.

The word idiot comes from two Greek words which mean "out of mind."

It has become a commonplace expression in our more recent culture on the planet.

Apparently, it was also considered an unacceptable practice when condemned by the Nazarene about 2 millenium previous warning of a very severe penalty for those who wish to call their fellow human beings such terms.

Narue commented: Idiot. ;) -4
hkdani 39 Posting Pro in Training

Post the exact error message.

With Turbo C 2.01 I tried a simple "Hello, World" program. I started in a different directory from the TC path. I just typed in the path: e.g. C:\Documents and Settings\hkdani\My Documents\cfiles > c:\tc\tc.exe.

I compiled the program and it ran fine. And the PATH environment variable did not include c:\tc. So, I imagine your problem comes from a faulty installation. If it can't find the stdio.h header file, then it may very well be that the stdio.h file is not installed or not installed properly for whatever reason.

Check the sub-directories of your Turbo C installation. See that you have an include directory, and check that you have the stdio.h file inside the include directory.

hkdani 39 Posting Pro in Training

You're certainly welcome. I knew you could do it.

hkdani 39 Posting Pro in Training

Use a timer control.

Set the interval property to 1000 milliseconds.
Use the enabled property to start and stop the timer.
Use static variables inside the timer functions to store minutes, seconds.

Just a few suggestions to get you started. But as WaltP pointed, you haven't posted any code. If you have not put forth any effort, how do you expect to develop your talents?

Put some work in. And you'll find that you'll put out some results.

hkdani 39 Posting Pro in Training

"9 bytes in stdin", what's that extra byte? does anyone know?

The debugger knows. All you have to do is ask. Just put a stop at the appropriate line in you code, preferably before the values inside stdin go out of scope.

hkdani 39 Posting Pro in Training

.I mean system date in OS.

Viaual Basic has no direct way of doing that. You have to use Win 32 API calls to do that.

If you want to just show the International Control Panel, do the following Shell "Control.exe intl.cpl" To set the format settings for the OS without having user intervention, you probably have to use CPIApplet API with the CPLINFO and NEWCPLINFO structures. This involves moderate to advanced knowledge of the C programming language, and also requires moderate to advanced experienced in working with the Windows APIs.

But you can declare these functions in Visual Basic as well as the structures and you should be able to do what you desire using VB6. You have asked a difficult question.

hkdani 39 Posting Pro in Training

lpClassName [in, optional]
Type: LPCTSTR

A null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined system class names(MSDN 2010).

Here's a partial list. Apparently, there may be others since you can use the TOOLBARCLASSNAME constant in the second parameter for the second parameter.

But with the following you just need to enter this as a string value: e.g. "Button", "ComboBox", etc.:

Class Description
Button The class for a button.
ComboBox The class for a combo box.
Edit The class for an edit control.
ListBox The class for a list box.
MDIClient The class for an MDI client window.
ScrollBar The class for a scroll bar.
Static The class for a static control.

hkdani 39 Posting Pro in Training
  1. You'll need to use the list Property of the list box control.
  2. You'll need to use some kind of loop to search through the values of the list.
  3. You'll use your code to match the value of the text box to the value of the item in the List box.

A few pointers:

  1. Find the total of the list count first by using one of the properties of the List Box
  2. Use the List property with its Index value to return the value of that index in the list.
  3. Use the selected property of the list control to with the same index value to select the item in the list.
  4. Use exit to exit out of your loop when you've found the answer.

Here's a few lines of code to get you started:

Private Sub cmdListHighLight_Click()
    Dim strSearch As String
    Dim intCounter As Integer, intListTotal As Integer
    '
    strSearch = txtInput
    intListTotal = lstResults.ListCount - 1
    
    For intCounter = 0 To intListTotal
        ' Enter your code here.
        ' You don't have to use a for loop.
    Next
    
End Sub
hkdani 39 Posting Pro in Training

I tried compiling the TOOLBAR using the CreateWindowEx function and was able to
make it work using similar headers to yours. Only I didn't use the hdrstop pragma and I included wingdi.h
I don't think that first suggestion I gave you will work.

But I looked into one of my resource.h header file I was using to compile
some of the controls with and this is what I found inside:

#define WINVER	    0x0501
#define _WIN32_WINNT	0x0501

I recall having some similar message a couple weeks ago. And after looking through the header files, I had found some defines and had to add these to get the status bar I was adding to compile. I think I was using some of the newer constants for the status bar display: SBARS_SIZEGRIP and they weren't recognized unless setting WINVER or _WIN32_WINNT to a higher version number.

I didn't use the IDE. I compiled straight from the command line using my own custom Makefile.

hkdani 39 Posting Pro in Training

There's really not much difference in setting up a local or wide area network. You just have to have a network connection. Logon to a shared directory on the server. And preferably map that location or shared resource as a drive on the client system.

It should then show up as a drive using your typical common dialog functions or controls that deal with loading drive resources on the client system.

Then you just log in to shared database files with the proper credentials. It's not that difficult.

hkdani 39 Posting Pro in Training

Check your defines for _WIN32_IE?

Needs to be defined >= 0x0400 for
TBSTYLE_SEP
TBSTYLE_BUTTON

You can do this in your Resource.h file

#define _WIN32_IE >= 0x0400

Also, Microsoft recommends using the CreateWindowEx over using the deprecated CreateToolbarEx. Use TOOLBARCLASSNAME in the second parameter with CreateWindowEx

hkdani 39 Posting Pro in Training

Yes, but you'll avoid problems with VB6 if you use the Option Explicit Option. This forces you to declare your variables as a certain type: e.g. integer, single. double, string, date, etc.

Following this practice can save you a lot of headaches down the road.

If you don't use Option Explicit, then if you declare a variable it will be used as what is called a Variant variable. This means you can use this variable for numbers, characters, strings, floating point values, whatever.

You use Option Explicit at the top of the form when you first start a program. Or you can set it in the Tools Menu under the Options SubMenu item.

Check the box that says: Require Variable Declaration.

The program will then complain that you haven't declare a variable as a certain type. But I stress, you must do this when you first start. If you start and then change it later, the program will just ignore the Option Explicit.

Here's a few spelling corrections:

Tuesday --> Not Tusday
Thursday ..> not Thirsday
Saturday --> not Saterday

hkdani 39 Posting Pro in Training

You're using VB.Net.
This is VB6. I don't have much experience with VB.NET. You might try on that forum.

hkdani 39 Posting Pro in Training
Dim lngReturn As Long
lngReturn = Shell("c:\MyProgams\cfile.exe", vbNormalFocus)
hkdani 39 Posting Pro in Training

Wouldn't it be nice to have a sizable command button in VB6? Face it. In the hidden recesses of your mind you have always wanted to be able to resize that command button in VB6--after the program is running that is. It's just that VB6 has not provided you with a control you could just drop, double click, or paste onto your form that allows you that capability.

Well, this tutorial should show you how to have your own sizable command button. You can resize it. And that's cool, But you'll have to do further modifications, if you want to respond to click events, down states, up states, etc. If the response on this short tutorial is sufficient, I plan to post a tutorial on how to add those events to your VB6 program.

Option Explicit
Private Const WS_THICKFRAME = &H40000
Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
Private Const BS_PUSHBUTTON = &H0&
Private Const WS_SIZEBOX = WS_THICKFRAME

Private lngSizeButton As Long

Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _
    (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, _
    ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
    ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, _
    ByVal hInstance As Long, lpParam As Any) As Long
    
Private Sub Form_Load()
    lngSizeButton = CreateWindowEx(0, "Button", "&Sizeable Button", WS_SIZEBOX Or BS_PUSHBUTTON Or WS_CHILD _
        Or WS_VISIBLE, 10, 10, 200, 100, Me.hWnd, …
hkdani 39 Posting Pro in Training

Apparently, your text file has input something like the following:

George, 99
Lisa, 82
WaltP, 100


Each line in the text file can be assigned to a variable. And then you can declare a variable to keep track of the information. One popular method is to declare your own type. Custom types are great for related information.

Private Type Student
    strName As String
    intGrade As Integer
End Type

' ...............

Dim MyStudents(100) as Student

Since you are using a comma separated value (CSV) text file as a source of data, use the Instr function to determine where the comma is and then save the data:

Dim strInput as String, intPlace as Integer 
     
intPlace = Instr(1, strInput, ",", vbTextCompare)

That will tell you the place of the comma in the string input value; and then you can use the Right or Left string operations to separate the values and store them into the Student type. If you need help on inputting data from a file, post some of you what you have attempted and we'll see if we can help you out.

But that along with BitBlt's suggestions should get you started.

hkdani 39 Posting Pro in Training

getchar() by definition operates on a character.

A character is defined as one of the input results you find defined on the ASCII chart.

'\n' is a character on the ASCII chart. You can use '\n' with getchar()

hi there)
guys , please tell me - is there any way to check that the standart input is empty or no.
big thanks in advance)

Just assume that the getchar() function has prepared stdin for use. Mainly, because it has.

Your job is to deal with the results of getchar(). If you feel uneasy about the state of stdin before calling getchar(), then use a debugger to step into the assembly code language to verify that it has done the job it was programmed to do.

But the answer to your question is yes.

hkdani 39 Posting Pro in Training

format(date, "dd-mm-yyyy")

hkdani 39 Posting Pro in Training

So as I think (and need) sould be a way to avoid this stopping.

These functions are designed to be used with '\n'

If you don't like the function, don't use it. Design your own.

hkdani 39 Posting Pro in Training

DebAsisdas gave a useful suggestion. I've never done it that way. Here's some further information along those lines from the MSDN documentation.

Creating a Front-end Database Application with Minimal Code
It's possible to create a database application using a minimum of code by setting a few properties at design time. If you are using an OLE DB data source, the Microsoft Data Link Name (.UDL) must be created on your machine. See "Creating the Northwind OLE DB Data Link" for a step-by-step example.

To create a simple front-end database application

Draw an ADO Data Control on a form. (The icon's ToolTip is "ADODC.")
If the control is not available in the Toolbox, press CTRL+T to display the Components dialog box. In the Components dialog, click Microsoft ADO Data Control.

On the Toolbox, click the ADO Data Control to select it. Then press F4 to display the Properties window.


In the Properties window, click ConnectionString to display the ConnectionString dialog box.


If you have created a Microsoft Data Link file (.UDL), select Use OLE DB File and click Browse to find the file on the computer. If you use a DSN, click Use ODBC Data Source Name and select a DSN from the box, or click New to create one. If you wish to use create a connection string, select Use ConnectionString, and then click Build, and use the Data Link Properties dialog box to create a connection string. After creating the connection string, …

hkdani 39 Posting Pro in Training

Microsoft gives it you. Borland gives theirs for the common run time. Usually, it's in the VC dircectory usually called something appropriately like src. And I'm sure that Gnu GCC gives it to you. It is open source.

You could use WinDbg, gdb (Gnu debugger), td32 (Borland's command line debugger) and step through, step into the source code and see for yourself. You can check the actual assembly language being used as your program executes. But that's another topic..............................

hkdani 39 Posting Pro in Training

I told you there were errors in the code. I left them in there. And you found one. Now you need to fix it. I don't mind helping you. But I just felt that your friend should do some of the work. Nevertheless, WaltP has graciously pointed out the error for you in line 28 which is listed quite clearly in a previous post as the following (see line 28 in previous post): Line Input #lngFileEngland, strArray(intCounter) By the way, did I say that was line 28?

I threw away the code here. Don't need it. But what I had originally considered was storing each line in an array of string: Dim strArray(7) as String. That way you could save each line in the array for future reference within the function. But after seeing the code in action, I determined I didn't need an array. So I removed the array changing strArray(7) to just strArray. Hence, the error I knew would arise, if you tried to run the code as is. Apparently, not only does your friend in Sweden have VB6, you must have Visual Basic also.

At first the original code contained a fixed array of strings ( strArray(7) ) that would hold the days of the week as they were being loaded inside the Do Loop. Since VB6 arrays are by default zero based--meaning the first index starts with 0--this will actually give you 8 days. So, technically you could use strArray(6) and have 7 String …

hkdani 39 Posting Pro in Training

I would say that you need to test for what the user has done. Not for what he hasn't done. The functions that use stdin take care of initializing the stdin buffer. Your job is to check what the user has put into the buffer after your function calls for use to stdin.

If you really want to know what's going on, find the source code for getchar() or whatever function you're calling to check the input from stdin. That should show you what takes place before you prompt the user for information from the keyboard.

There's no need to reinvent the wheel, if you have one already.

vedro-compota commented: ++++++++ +3
hkdani 39 Posting Pro in Training

I would recommend VB over C for working with Access database files. Writing code for C is more complex for working with Access Databases. Of course, a typical C programmer likes things more complex, anyway.

But Visual Basic 5, 6 was basically built to run Access databases and is fairly easy to implement. You may have finer control in a C program, but I'll doubt you'll need it or want the headaches of having to figure it out in C.

I've been programming for years. But for Rapid Application Development, I would say you just can't beat VB.

Argh. The C programmers are going to tell me to stay on the VB forum again.

hkdani 39 Posting Pro in Training

i am using the adodb as my recordset..what should i put as my recordsource?

There are different ways to open a recordset.
I usually do the following:

Dim cnAdodb as ADODB.Connection
Dim rst as ADODB.Recordset

Dim strSQL as String 
set cnAdodb = new ADODB.Connection
set rst = new ADODB.Recordset

strSQL = "Select * from Data where No_Id like'" & Text1.Text & "*'"
With cnAdodb
     .Provider = "Microsoft.Jet.OLEDB.4.01" ' Enter the name of your provider
     .Open "C:\MyDatabaseFiles\Mydatafile.mdb", "admin", ""
End With

rst.Open strSQL, cnAdodb, adOpenDynamic, adLockOptimistic


' Close out ADODB objects and reclaim memory set aside for them.
rst.close
cnAdodb.close
set rst = Nothing
set cnAdodb = Nothing

is it possible that i dont have to use any listbox or dbgrid to display the result just within the textbox,,,tnx...

If you set the text property Multiline to True, then you can use the Textbox for more than one line.

hkdani 39 Posting Pro in Training

Here's some sample code. Return the favor someday.

There are some errors in the code. And code for what to do for Greece has not been included. Your friend will have to find the errors and fix them. And he will have to do some thinking about how to deal with the day in Greece.

But this should help y'all out.

Option Explicit
Dim strNameEngland As String, lngFileEngland As Long, strLeneng As Long ' för England
Dim strToday As String
Dim lngStrLength As Long

' strtoday = Format, "dddd") ', "d")


'Do Until EOF(Fnumeng)
'
'Line Input #Fnumeng, namneng
'
'If Left$(namneng, 1) = today Then
'
'strLen = Len(namneng)
'
'Label2.Caption = Right$(namneng, strLen - 6)

Private Sub cmdOpenFile_Click()
    Dim strArray As String
    Dim strTemp As String
    Dim intCounter As Integer, intDate As Integer, intFileDate As Integer
    intDate = Weekday(Date, vbMonday)
    lngFileEngland = FreeFile
    Open App.Path & "\Dani.txt" For Input As #lngFileEngland
    
    Do Until EOF(lngFileEngland)
        Line Input #lngFileEngland, strArray(intCounter)
        
        intFileDate = CInt(Left$(strArray(intCounter), 2))
        
        If intFileDate = intDate Then
            lngStrLength = Len(strArray(intCounter))
            lblDate.Caption = Right$(strArray(intCounter), lngStrLength - 2)
            Exit Do
        End If
        
        intCounter = intCounter + 1
        
    Loop
 
    
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Close #lngFileEngland
End Sub
hkdani 39 Posting Pro in Training

Just a little code to help you with your assignment

Const LAZY_BUM = 0
Const HARD_WORKING_STUDENT = 1

Private Sub Form_Load()
     Dim i as Integer
     i = MsgBox("Am I a good student student?", vbYesNo, "Character")
     
     If (i = vbYes)
          MsgBox "The test of your character is what you do when no one else is watching.", vbInformation, "Test Grade"
     else if(i = vbNo)
          MsgBox "Better to get work on that character, buddy.", vbExclamation, "Now!"
     End if
End Sub

Private Sub MyLife()
     ' It's your choice. Write the code. And remember. There's more to life than 1's and 0's.

End Sub
hkdani 39 Posting Pro in Training

Try looking inside what's inside stdin. It's just a buffer that has a memory address.
Is there a reason why you can't peek around?

#define stdin (&_iob[STDIN_FILENO]) (MinGW: Stdio.h)

hkdani 39 Posting Pro in Training

Try using a file and assigning to stdin?

/*
* The structure underlying the FILE type.
*
* Some believe that nobody in their right mind should make use of the
* internals of this structure. Provided by Pedro A. Aranda Gutiirrez
* <paag@tid.es>.
*/
#ifndef _FILE_DEFINED
#define _FILE_DEFINED
typedef struct _iobuf
{
char* _ptr;
int _cnt;
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char* _tmpfname;
} FILE;(MinGW Include: stdio.h).

#include <stdio.h>

int main(void)
{
    FILE *pFile ;
    int i ;

    pFile = stdin ;
    i = (int) sizeof (stdin) ;
    printf("%d bytes in stdin\n", i) ;
    
    for (i=0 ; pFile->_ptr[i]; i++)
	printf("%c", pFile->_ptr[i]) ;

    printf("\n%d count, %d bufsiz\n", pFile->_cnt, pFile->_bufsiz) ;
    return 0 ;
}
hkdani 39 Posting Pro in Training

Then include the functions.h in the first file and remove the #include <stdio.h> from the second file otherwise you will be pulling that in twice.

That's the preferred way to do things: insert the functions you wish to use in a header file, and then use an include statement. #include "MyHeader.h" User added headers not found or set in the INCLUDE environment path, need to be quoted using the actual path names. If the header is in the same path as the source file, then you can just use quotes. Otherwise #include "c:\My Headers\Myheader.h" But if the user doesn't want to use a header file, he needs to use the extern keyword on the prototype for the function. The compiler linker needs this so that it won't mangle the names. It searches and prevents compilation and linking of the files, if it finds duplicate declarations of variables, functions, etc.

hkdani 39 Posting Pro in Training

Well, you have to understand the LB_FINDSTRING is a constant that applies to a listbox control. So, you can send that message to a listbox control and it should work.

But you want something that works with a listview control:

More than likely this is the constant you are looking for:
LVM_FINDITEM SendMessage(ListView1.hWnd, LVM_FINDITEM, -1, ByVal(Cstr(Text1.Text)) The 1st parameter asks for the handle of the window, the second the message constant, and the third asks for what position to start at(-1 means the beginning), and the fourth is the text you want to search for).

You can find a list of messages that apply to the ListView from the Current Platform SDK. You can do a search in the MSDN Library with the following words: List View Messages (Windows).

There are about 49 or 50 messages you can send to a ListView control. They all start with LVM_--which is probably an acronym for List View Message.

And you will need to define the value of the LVM_FINDITEM or the constant you want to use. You can use a text editor to search for the value: open up the commctrl.h header file found in the include directory of the Platform SDK, or you can find that file in the VC\Inlcude directory, if you have a copy of VC++ installed somewhere. They usually list the values for the constants inside these header files.

Something like #define LVM_FINDITEM 0x00008000 Which means it has a hexadecimal value …

hkdani 39 Posting Pro in Training

the error appear on the line rs.open in my else condition...why?

Well, now we're getting somewhere. That helps.

"Select * from tblpos where category like '" & cbocategory.Text & "' and date between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "';", cn, adOpenKeyset, adLockOptimistic

I see you're using single quotation marks '

Try using double quotation marks. I've had trouble with that before. Using double quotation marks seems to do the trick.

Working with dates in SQL statements connecting to databases is kind of tricky. Sometimes it helps to stick them in a SQL Designer and test them to see if your SQL statements are actually working.

hkdani 39 Posting Pro in Training

No, the SendMessage API is used to send a message to the Windows Procedure of a window. In VB6, you're kind of limited as to what messages you receive unless you subclass the window procedure, which is probably something you don't want to get into. It's not too stable in the VB6 environment. But to use that you need to use the GetWindowLong API to obtain an address to the Window Procedure, and then you have to intercept the messages in your own window procedure, transfer the messages back to the orignal procedure, etc.

In the process, your VB6 environment crashes 10 or 20 times before it starts to work. And then maybe it works. Maybe. But if does start to work, then .............

But The SHAutoComplete API mentioned in the link you gave is for filesystems and URL's and is found in the shlwapi dynamic link library. But you want auto completion to work based on a result from a SQL search into a recordset.


But what you're asking for is something that you have not supplied any attempted code for.

Let's see what you've got.

Well, maybe that SendMessage will work. A listview is a window. And it looks like someone has figured out how to use it in VB6 on that link.

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As …
hkdani 39 Posting Pro in Training

Working with Excel Sheets is not too well documented anywhere.
So, here is some code to open up an existing excel worksheet.
But you have to know the worksheet name. And you have to be aware
of what the Actual Row and Column is.
If you know you have values in A1 and A2, then you could input
those values into txtCellValue.Text, the value in that range (if valid)
should appear in txtResult.

Option Explicit
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlBook2 As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Private Sub cmdDisplay_Click()
    txtResult = xlSheet.Range(txtCellValue.Text).Value
End Sub

Private Sub Form_Load()
    Set xlApp = New Excel.Application
    Set xlBook = xlApp.Workbooks.Open("f:\temp.xls")
    Set xlSheet = xlBook.Worksheets("MySheet")
End Sub

Private Sub Form_Unload(Cancel As Integer)
    xlBook.Close
    xlApp.Quit
    Set xlApp = Nothing
    Set xlBook = Nothing
    Set xlSheet = Nothing
End Sub

Hope this gets you started.

Regards,

Hank

hkdani 39 Posting Pro in Training

I tried to open a connection from an Excel file to itself as if it were an external database, only to be told by the Wizard that it does not contain any tables. And I don't know whether this is a problem within the Excel file or due to it trying to connect to itself.

No way to really help you. At least I can't help you.

Please post the code you used to connect to the Excel File. And please post your Sequel Statement. We may have experience in making connections and using SQL statements. But not too many of us here are warlocks or witches or have a direct connection with God that allows us access to the private information within the inner recesses of your brain.

hkdani 39 Posting Pro in Training

No, you don't understand.
You've already defined a struct at the beginning. You need to declare an array to the struct you've declared.

struct word_length MyWord[MONTHS] ; 
// And then you need to fill in the values in your for loop
MyWord->word = "January" ;
MyWord->count = strlen("January") ;

This is just one way to do what you want. There are other ways. You should read up on how to declare structs and how to use them. Based on the posts you've been listing here, you haven't done your homework. And that is My Word for the day

You can use your way. But I believe your instructor wants you to use the strlen function. You're not doing that. What is the length of "January"? It's certainly not 0. Be sure to read your instructor's instructions carefully. Otherwise, everything may come out correctly. But since you have not been careful to follow instructions, you may not get the grade you want.

You need to fill in the values in the manner he requests.

Then within for-loop, find the length of each month using strlen from string library,
and update the array.

I don't believe you will pass this part of the assignment.

hkdani 39 Posting Pro in Training

You don't need to initialize the array at first.

But you should define an array after

int main(void) // use void, don't leave it blank
// declare your array to your previously defined struct here.
// I'm not going to do it for you.
int i ;

for (i = 0; i <12; i++)
{
     // Fill in the values for your *struct here.
}

That should get you going along the right direction. If I would do more, I should probably sign up for your class and receive credit.

minimi commented: Thank you! +2
hkdani 39 Posting Pro in Training

Don't use the second include line in the first file. You don't need that.

Use the extern keyword in the first file on lines 5 and 6: Since these functions are external to this file and are found in the second file.

And then compile your file on the command line as follows:

gcc -o function.exe functions.c funct.c

I don't know what you called both of your file names. Or I just didn't pick it up. But this compiled with gcc 4.5.2 without warnings and produced the following result:

35
36
35

The reason you have that error message of multiple definitions is because you have not used the extern keyword in the first file.

hkdani 39 Posting Pro in Training
Private Sub Text1_Change()
    On Error GoTo ErrMsg
     
    Dim LstItm As ListItem
    Dim Strt as Integer
    With ListView1
        .FindItem(Text1.Text, , , 1).Selected = True
        'If something was chosen then we get the rest of it
        strt = Len(Text1.Text)
        
        Text1.Text = .SelectedItem.Text
        Text1.SelStart = strt
        Text1.SelLength = Len(Text1.Text) - strt
        
    End With 
    Exit Sub
    ErrMsg:
    ListView1.SelectedItem.Selected = False
    End Sub

You can use With and End With to marginally speed up the process. Not much of a savings here, but some. Or try With .. End With around the Text1. .... statements. But I would say that the ListView Control has more overhead than the TextBox Control. So, you might be further ahead to use the With / End With around the ListView. Any time you can use With and End with, you prevent the program from having to reload an object. So try to use these whenever you can to improve program efficiency.

Other than that, you could call Windows API's for the ListView Control, and allocate memory on the heap bypassing VB6's ListView control.

hkdani 39 Posting Pro in Training

First of all, it would help for readability to use what are universally accepted variable declarations for variables.

For example, use str at the beginning of a string variable, int at the beginning of an integer, lng at the beginning of a long variable, etc.

strDateGreece as String ' as opposed to iDag as string
lngStrLength as long ' as opposed to strLenEng as long

Experienced programers used to accepted standards could easily mistake your variables for the wrong type.

See if your friend could rewrite this. Then we'll take a closer look at it.