Jump to content


Photo

Programming Languages


  • Please log in to reply
86 replies to this topic

#41 Azat

Azat

    Veteran

  • Members
  • PipPipPipPipPip
  • 8,969 posts
  • Gender:Male
  • Location:Los Angeles, CA
  • Interests:wine, beer, food, art, jokes

Posted 22 February 2002 - 09:50 PM

Harut, maybe you can say what you are trying to accomplish and I can assist you.

#42 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 22 February 2002 - 11:24 PM

quote:
Originally posted by Harut:


yesterday i picked up my books for coming term. two of which are "C++ How To Program" from Deitel & Deitel, and "Object-Oriented Programming Using C++" from Course Technology.

i briefly went over the intros, and somewhere there it mentions that link. it says we can download a free copy of Borland C++ from there.
i haven't checked it out yet. i'll do it now.

but i don't understand one thing.
does it matter which compiter i use? isn't C++ C++ whatever i use it with?

i got Visual Studio 6. is it good or bad?


That Dietel and Dietel book is excellent. That's also the same one UCLA uses to teach intro to C/C++.

Visual Studio 6 is the best development environment ever made! Microsoft's C/C++ compiler is also very good.

C and C++ should be the same as long as you stick to the ANSI standards. ANSI C is very well defined but C++ is still being changed. New features are being added and removed and some compilers may or may not support some features. However, almost all compilers support the basic stuff so your choice of compiler will not make a difference.

The only thing is that don't confuse development environment and compiler. Visual Studio can make it seem like everything is integrated together but the complier is a separate program. Microsoft's 32-bit C/C++ compiler is called cl and you can use it to compile programs without using the Visual studio environment.

Although most people will use the Visual C++ environment to work on their programs (somewhat like how you would work on a visual basic program). But at the end, CL is compiling your code into an executable.

There are other compilers like GCC (gnu compiler) that I use a lot. But stick to Visual C++ since you already have it. It is very very good! (make sure you install the latest service packs from microsoft ... I think the latest is SP5. They fix a lot of bugs with the compiler). You can download Service Pack 5 from HERE (it's about 130MB) .

[ February 22, 2002: Message edited by: Sip ]

#43 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 23 February 2002 - 12:16 PM

ok, here is what i want to do.
i have a combo box, style = simple combo.
it contains a lot of names.
let's say:
"Azat"
"Garo"
"Gnel"
"Harut"
"Movses"
"Sip"
they are sorted.
now, when the user type the first letter, let's say "G", then the first name with "G" gets selected in the list portion, which is in this case "Garo".
if user types "n" next, then "Gnel" should get selected.
and so on.

#44 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 23 February 2002 - 12:18 PM

quote:
Originally posted by Garo:


What is the purpose of this sub?
There are 2 ways to make an item selected
1. listbox has a property that stores the selected item's index. you can change this property and assign the correct value.
2. list items have boolean property 'selected' which is true for the selected item. Assign true to that item's 'selected' property and it'll become selected.

I'm not sure about the exact syntax in VB.



yes el hents et "Selected" propertyn em uzuzum gtnem chem karoghanum.
i guess there is no such a thing in VB.

#45 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 23 February 2002 - 12:20 PM

quote:
Originally posted by Sip:


That Dietel and Dietel book is excellent. That's also the same one UCLA uses to teach intro to C/C++.

Visual Studio 6 is the best development environment ever made! Microsoft's C/C++ compiler is also very good.

C and C++ should be the same as long as you stick to the ANSI standards. ANSI C is very well defined but C++ is still being changed. New features are being added and removed and some compilers may or may not support some features. However, almost all compilers support the basic stuff so your choice of compiler will not make a difference.

The only thing is that don't confuse development environment and compiler. Visual Studio can make it seem like everything is integrated together but the complier is a separate program. Microsoft's 32-bit C/C++ compiler is called cl and you can use it to compile programs without using the Visual studio environment.

Although most people will use the Visual C++ environment to work on their programs (somewhat like how you would work on a visual basic program). But at the end, CL is compiling your code into an executable.

There are other compilers like GCC (gnu compiler) that I use a lot. But stick to Visual C++ since you already have it. It is very very good! (make sure you install the latest service packs from microsoft ... I think the latest is SP5. They fix a lot of bugs with the compiler). You can download Service Pack 5 from HERE (it's about 130MB) .

[ February 22, 2002: Message edited by: Sip ]


thanks Sip.

i have been downloading that thing you are talking about for 4 months now.
i reach 15% mark finally.

#46 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 23 February 2002 - 12:44 PM

Harut jan,

I just wrote this code which I think does what you are asking. Just copy-paste it code into a text file, call it something like list.frm, and open and run it in VB.

It basically lets you add items to a list, and then select either the next item or the previous item. Is this the "select" you are asking about?

code:

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1890
ClientLeft = 60
ClientTop = 345
ClientWidth = 3210
LinkTopic = "Form1"
ScaleHeight = 1890
ScaleWidth = 3210
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command3
Caption = "Select Prev"
Height = 495
Index = 0
Left = 1680
TabIndex = 3
Top = 1320
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "Select Next"
Height = 495
Left = 1680
TabIndex = 2
Top = 720
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "Add Items"
Height = 495
Left = 1680
TabIndex = 1
Top = 120
Width = 1455
End
Begin VB.ListBox List1
Height = 1620
Left = 120
TabIndex = 0
Top = 120
Width = 1455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
newItem$ = "Item " + Str(List1.ListCount + 1)
List1.AddItem (newItem$)
End Sub

Private Sub Command2_Click()
If List1.ListCount > 0 Then
sel = List1.ListIndex
sel = sel + 1
If sel >= List1.ListCount Then sel = 0
List1.Selected(sel) = True
End If
End Sub
Private Sub Command3_Click(Index As Integer)
If List1.ListCount > 0 Then
sel = List1.ListIndex
sel = sel - 1
If sel < 0 Then sel = List1.ListCount - 1
List1.Selected(sel) = True
End If
End Sub



#47 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 23 February 2002 - 09:38 PM

Sip jan, that wasn't quite what i wanted but it helped me see how the Selected property works.

now i think i know how to do what i wanted to do. so i'll post it to show you shortly.

#48 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 23 February 2002 - 10:46 PM

ok guys i found it!!!

here is what i wanted to do so long.
this time i used a text box and a list box.
before i was using a simple como box, but unfortunatly it doesn't support the Selected property. .
anyways. i guess i have to use separate text box and a list box.

thanks for your help people.

quote:
VERSION 5.00
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 1920
ClientLeft = 60
ClientTop = 345
ClientWidth = 3855
LinkTopic = "Form2"
ScaleHeight = 1920
ScaleWidth = 3855
StartUpPosition = 3 'Windows Default
Begin VB.ListBox lstTest
Height = 1230
ItemData = "Form2.frx":0000
Left = 120
List = "Form2.frx":001F
TabIndex = 1
Top = 600
Width = 3615
End
Begin VB.TextBox txtTest
Height = 285
Left = 120
TabIndex = 0
Top = 120
Width = 3615
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub txtTest_Change()
Dim I As Integer
Dim L As Integer

L = Len(txtTest.Text)
For I = lstTest.ListCount - 1 To 0 Step -1
If LCase(txtTest.Text) = LCase(Left(lstTest.List(I), L)) Then
lstTest.Selected(I) = True
End If
Next I
End Sub



#49 Garo

Garo

    Veteran

  • Admin
  • PipPipPipPipPip
  • 1,096 posts
  • Gender:Male
  • Location:Los Angeles

Posted 24 February 2002 - 09:55 AM

quote:
Originally posted by Harut:
ok guys i found it!!!

here is what i wanted to do so long.
this time i used a text box and a list box.
before i was using a simple como box, but unfortunatly it doesn't support the Selected property. .
anyways. i guess i have to use separate text box and a list box.

thanks for your help people.



To make an item selected in combobox you use its TextColumn property.
From the VB help file:
When the user selects a row, the Text property of the control is set to the value of the column identified by the TextColumn property. In a combo box, the system displays the column designated by the TextColumn property in the text box portion of the control.


#50 Azat

Azat

    Veteran

  • Members
  • PipPipPipPipPip
  • 8,969 posts
  • Gender:Male
  • Location:Los Angeles, CA
  • Interests:wine, beer, food, art, jokes

Posted 25 February 2002 - 08:54 AM

Harut,
Sorry for the late reply.

The ".Text" property of the combo box will give you the item that is currently selected.

Also I think what you are trying to accomplish can easily be done by just changing the combo box "style" property to a dropdown list. One warning, when it is a list you cannot add new items to your list, you have to do it programmatically.

Hope that helps.
Azat

#51 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 10 April 2002 - 01:06 AM

guys i need help with C++!!!

my prof assigned an extra work that i really want to do. it involves Console Graphics.
he doesn't help us in anyway, excapt that he told us in what book to look for this stuff.

i've got the book. everything seems to be easy and fun, but the book refers to MSOFTCON.CPP file, which supposedly is on my computer. however it is not.

so, now i'm just stuck. do you guys have any suggestions???

#52 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 10 April 2002 - 01:40 AM

What do you mean by console graphics? I have never heard of such a thing. You mean graphics using "ASCII" art?

C/C++ has no standard thing for graphics. You have to use special libraries (like OpenGL, etc) or do it in Windows. Either way, I could help I think so don't worry ... just give me some more details (what compiler are you using and what you have to do)

#53 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 10 April 2002 - 01:51 AM

Ok I found out what it is. It is pretty interesting ... it does graphics using text as I was suspecting !!!

I found the files you want and a sample program at some site. I compiled it with Visual C and everything works great. I put a zip file with the source and my compiled exe at CLICK HERE.

I compiled using >cl circles.cpp msoftcon.cpp
(circles is the program and msoftcon is the "library". Circles includes the msoftcon.h file so you need that too)

In case you need more info or the Visual C project files, go to THIS SITE.

Happy coding!!!

#54 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 10 April 2002 - 09:08 AM

thank you Sip. this was exactly what i was looking for.

the sample code you gave is acctually in my book.
i just didn't have those msoftcon files.

well, i think it's time for me to start using google.

#55 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 10 April 2002 - 09:25 AM

Sometimes it is pretty amazing what you can find on Google! Also, www.deja.com is a very good source. Now it redirects to http://groups.google.com and it basically searches all newsgroup archives.

Can you believe I am almost done with university and I have been to the Library about 3 times? And even then, each time I go there to copy things on the copy machine I feel so shameful

#56 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 10 April 2002 - 11:35 PM

:)library? are you talking about that place where students take a nap in the smells of books?

#57 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 10 April 2002 - 12:52 PM

No I am talking about that place where most armenian/persian students at UCLA go to meet girls!!! On second thought ... maybe I should have gone to the library much much more to "study" and "read"

#58 Azat

Azat

    Veteran

  • Members
  • PipPipPipPipPip
  • 8,969 posts
  • Gender:Male
  • Location:Los Angeles, CA
  • Interests:wine, beer, food, art, jokes

Posted 10 April 2002 - 08:06 PM

Dohhhhhhhh! is that where they hang around? I am an idiot, I should have spent more time in the library.

#59 Harut

Harut

    Վերնագիր

  • Members
  • PipPipPipPipPip
  • 5,734 posts
  • Gender:Male
  • Location:հորիզոն...
  • Interests:uninterested...

Posted 15 May 2002 - 10:46 AM

guys, i'm having a little problem with C++.
here is a mini program i just wrote. i guess you can figure out what it does.
the problem is at the duplicate part.
when i enter numbers such as

1 2 3 4 5 6 7 8 9 1

it works fine.

but when i enter numbers such as

1 2 3 4 5 6 7 8 1 1

it shows duplicate numbers three times, one for each pair of matching numbers ( first nineth, first tenth, nineth tenth ).

any suggestions how i can accomplish what i want?

code:
 // Lab 10
// 1-D Array Search
//
// Harut
// May 14, 2002
//
// This program is designed to accept 10 incomes from the user,
// find the highest one, find the lowest one, find any duplicates,
// and display them in reversed order

#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#define MAX_NO 10

int main()
{
int income[MAX_NO] = {0},
duplicates[MAX_NO] = {0},
num_dup = 0,
max,
min;
double total = 0,
average;

cout << "WELCOME!" << endl;

cout << "nPlease enter 10 incomes one by one" << endl;

for ( int i = 0; i < MAX_NO; i++ )
{
cin >> income[i];

total += income[i];

if ( i == 0 )
{
min = income[i];
max = income[i];
}

if ( income[i] > max )
max = income[i];

if ( income[i] < min )
min = income[i];
}

for ( i = 0; i <= MAX_NO; i++ )
{
for ( int j = ( i + 1 ); j <= MAX_NO; j++ )
{
if ( income[i] == income[j] )
{
duplicates[num_dup] = income[i];
num_dup++;
}
}
}

average = total / MAX_NO;

cout << "ntt***Household Income***" << endl;

for ( i = 0; i < MAX_NO; i++ )
cout << setw( 25 ) << income[i] << setw( 13 ) << income[MAX_NO - i - 1] << endl;

cout << "nThe highest income --- " << max << endl;
cout << "The lowest income ---- " << min << endl;
cout << "The average income --- " << setiosflags( ios::fixed | ios::showpoint )
<< average << endl;

for ( i = 0; i <= ( num_dup - 1 ); i++ )
{
if ( num_dup > 0 )
cout << "Duplicate income ----- " << duplicates[i] << endl;
}

cout << "nThank you for using the program!" << endl;

getch();

return 0;
}



#60 Sip

Sip

    Buffet Connoisseur

  • Members
  • PipPipPipPipPip
  • 8,366 posts
  • Gender:Male
  • Location:Online

Posted 15 May 2002 - 11:38 PM

First of all:

code:
for ( i = 0; i <= MAX_NO; i++ )	{
for ( int j = ( i + 1 ); j <= MAX_NO; j++ )

Watch out! The limit should be < MAX_NO not <=. Don't you just love C bugs?

Next question is, what does it mean to "find duplicates?" does it mean to print the duplicate income just once? (I am assuming that is what it means).

In that case, every time you see a duplicate (where you have income[i]==income[j]) you have to go and check in your existing duplicates array to see if that income has already been seen. If NOT, then you add it to that array. But if it is already in the duplicates array, then you don't add it. This means another loop in that IF.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users