Rabu, 01 April 2026

VB 6

 https://xxxmen.github.io/vb6/Promsvb6.htm?utm_source=openai


VB 6 Self Typing Demo 2

 

Option Explicit

 

Private Const FIXED_TEXT = "This is a demo of self a typing textbox effect."

 

Private Sub Form_Load()

    Timer1.Interval = 300

End Sub

 

Private Sub Timer1_Timer()

Timer1.Interval = 150 * Rnd

Static i%

 

    i = i + 1

    Text1.Text = Text1.Text & Mid(FIXED_TEXT, i, 1)

    If Text1.Text = FIXED_TEXT Then Timer1.Enabled = False

 

End Sub


VB 6 Self Typing Demo

 


Option Explicit
 
Private Const FIXED_TEXT = "This is a demo of selftyping textbox."
 
Private Sub Form_Load()
    Timer1.Interval = 100
End Sub
 
Private Sub Timer1_Timer()
Static i%
 
    i = i + 1
    Text1.Text = Text1.Text & Mid(FIXED_TEXT, i, 1)
    If Text1.Text = FIXED_TEXT Then Timer1.Enabled = False
 
End Sub


C++ From Year 1995 Bonus

 // Filename: BPROJ1.CPP

// This program displays the character for each ASCII value


#include <iostream.h>


void main()

  {

    // Output a heading

    cout << "Value   Character" << endl;

    

    // For all the characters (missing out the first

    // few unprintable characters.

    for (int i = 32; i <= 255; i++)

      {

         // Make the value print in 3 characters

         cout.width(3);

         // Print the value, followed by some spaces

         // followed by the character value and

         // finally a new line

         cout << i << "     " << (char)i << endl;

      }

  }

=====================

// Filename: BPROJ2.CPP

// This program demonstrates the basic structure

// of a C++ program 

#include <iostream.h>


void main()

  {

    // Declare and initialise variables

    int value1 = 10;

    int value2 = 20;

    int value3 = 40;                   

    // Declare a variable for working out the

    // sum of the numbers

    int sum;             

    // Declare another variable for the result

    int average;                              

    // Add three numbers into sum

    sum = value1 + value2 + value3;

    // divide the sum by the number of values to

    // get the average

    average = sum / 3;

    // Output the result

    cout << "The average of " << value1 << ", "

         << value2 << " and " << value3 << " is "

         << average << endl;

    cout << "The sum of the numbers is " << sum;        

  }

=====================

// BPROJ3.CPP 

// A simple review of character and numeric

// input and output.

#include <iostream.h>


void main()

  {

    // Declare variables

    int decimals = 0;

    float number;

    const int descLen = 80;

    char numberDesc[descLen];

           

    cout << "Enter a floating point number: ";

    cin >> number;

    cin.ignore(80,'\n');

    

    cout << "How many decimal places do you want? ";

    cin >> decimals;

    cin.ignore(80,'\n');

    

    cout << "How do you want to describe the number?" << endl;

    cin.getline(numberDesc,descLen);

    

    cout << endl;

    cout << numberDesc << ": ";

    

    // Format the number as requested

    cout.precision(decimals);

    cout.setf(ios::fixed);

    cout.setf(ios::showpoint);

    

    cout << number;

  }

=====================

// Filename : BPROJ4.CPP

// This project does some calculations

// and then tests them.


#include <iostream.h>


void main()

  {

    char burgerType = ' ';        

    char cheese = ' ';

    char fries = ' ';

    float burgerCost = 0.0F;

    float friesCost = 0.0F;

    float totalCost = 0.0F;

    

    cout << "Welcome to Spencer's Burger Bar!" << endl;

    

    cout << endl << "What sort of burger would you like?" << endl;

    cout << "[s]mall, [q]uarter pounder, [b]loatburger? ";

    cin >> burgerType;

    if (burgerType >= 'a' && burgerType <= 'z')

      burgerType += 'A' - 'a';

    if (burgerType != 'S' &&   burgerType != 'Q'

        && burgerType != 'B')

      burgerType = 'Q';

      

    cout << "Is that with cheese?";    

    cin >> cheese;

    if (cheese == 'Y' || cheese == 'y')

      cheese = 'Y';

    else

      cheese = 'N';

    

    cout << "[r]egular or [l]arge fries?";

    cin >> fries;

    if (fries == 'r' || fries == 'R' ||

        fries == 'l' || fries == 'L')

      {

        if (fries == 'r' || fries == 'l')

          fries += 'A' - 'a';

      }

    else

      fries = 'R';

     

    // Calculate cost - everything is relative

    

    burgerCost = 1.75F;

    if (burgerType == 'S')

      burgerCost *= 0.60F;

    if (burgerType == 'B')

      burgerCost *= 1.7F;                   

    if (cheese == 'Y')

      burgerCost += 0.50F;

      

    if (fries == 'R')

      friesCost = 1.00F;

    else

      friesCost = 1.50F;

      

    totalCost = burgerCost + friesCost;

    

    if (fries == 'L' && burgerType == 'B')

      {

        cout << "There is a special on the Bloat & large fries!" << endl;

        totalCost = totalCost * 0.9F;

      }

      

    cout << "That will be $";

    cout.setf(ios::fixed);

    cout.setf(ios::showpoint);

    cout.precision(2);

    cout << totalCost << "." << endl;

    cout << "Have a nice day!";

  }    

     

      

      

        

  =======================

// BPROJ5.CPP

// Switching and calculations explored

#include <iostream.h>


void main()

  {

    int method = 1;

    float f = 1.99F;

    int i = 10;

    float answer = 0;

    // This program simply demonstrates some rounding errors

    cout << "1. i * f" << endl;

    cout << "2. (int)(i * f)" << endl;

    cout << "3. i * (int)f" << endl;

    cout << "4. (int)(i * f) * f" << endl;

    cout << "5. (int)(i *f) * (int)f" << endl;

    cout << "Enter method: ";

    cin >> method;

    switch (method)

      {

        case 1:

          answer = i * f;

          break;

        case 2:

          answer = (int)(i * f);

          break;

        case 3: 

          answer = i * (int)f;

          break;              

        case 4:

          answer = (int)(i * f) * f;

          break;

        case 5:

          answer = (int)(i * f) * (int)f;

          break;

        default:

          cout << "Invalid input";

          return;

      } 

      

    cout << "The answer is " << answer << endl;

  }

============================

// Filename: BPROJ6.CPP

// Factors - a factor is a number that

// multiplied by another number exactly makes another number


#include <iostream.h>


void main()

  {

    int product = 1;

    while (product)

      {

        cout << endl << "Enter number to test:";

        cin >> product;

        if (product)

          {

             cout << "The factors of " << product << " are:" << endl;

             for (int i = 2; i < product ; i++)

               {

                 if (product % i)

                   continue;

                 cout << i << endl;

               }

          }

      }

  }

        

==============================
// Filename: BPROJ7.CPP
// Exporing function calls at the burger bar
#include <iostream.h>

inline char UpperCase(char c)
  {
    if (c >= 'a' && c <= 'z')
      return c + 'A' - 'a';
    else
      return c;
  }  
      
float PriceBurger(char burgerType,int withCheese)
  {        
    float burgerCost = 1.75F;
    if (burgerType == 'S')
      burgerCost *= 0.60F;
    if (burgerType == 'B')
      burgerCost *= 1.7F;                   
    if (withCheese)
      burgerCost += 0.50F;
    return burgerCost;  
  }  
  
float PriceFries(char fries)
  {
    if (fries == 'R')
      return 1.00F;
    else
      return 1.50F;
  }  
  
void GetBurgerType(char& burgerType, char& cheese)
  {    
    do
      {
         cout << endl << "What sort of burger would you like?" << endl;
         cout << "[s]mall, [q]uarter pounder, [b]loatburger? ";
         cin >> burgerType;
         burgerType = UpperCase(burgerType);
      }
    while (burgerType != 'S' &&   burgerType != 'Q'
           && burgerType != 'B');
      
    do
      {
         cout << "Is that with cheese?";    
         cin >> cheese;             
         cheese = UpperCase(cheese);
       }
    while (cheese != 'Y' && cheese != 'N');
  }

char GetFries()
  {    
    char fries;
    do
      {
         cout << "[r]egular or [l]arge fries?";
         cin >> fries;
         fries = UpperCase(fries);
      }
    while (fries != 'R' && fries != 'L');
    return fries;
  }
    
void Special(char fries, char burgerType, float& totalCost)
  {
    if (fries == 'L' && burgerType == 'B')
      {
        cout << "There is a special on the Bloat & large fries!" << endl;
        totalCost = totalCost * 0.9F;
      }
  }      

void main()
  {
    char burgerType;
    char cheese;
    
    cout << "Welcome to Spencer's Burger Bar!" << endl;
    GetBurgerType(burgerType,cheese);        
    char fries = GetFries();
    float totalCost = PriceBurger(burgerType, (cheese == 'Y')) 
                    + PriceFries(fries);
    Special(fries,burgerType,totalCost);
    cout << "That will be $";
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout << totalCost << "." << endl;
    cout << "Have a nice day!";
  }    
  =============================
// File name: BPROJ8.CPP
// Something interesting with arrays and pointers.

#include <iostream.h>

// A routine to return a value 0 for non-alpha
// and 1 to 26 for a to z in either upper or lowercase
inline int Letters(char p)
  {
    if (p >= 'a' && p <= 'z')
      return p - 'a' + 1;
    if (p >= 'A' && p <= 'Z')
      return p - 'A' + 1;
    else
      return 0;
  }
        

void main()
  {
    const int maxLen = 80;
    char input[maxLen];
    int letters[27] = {0};
    
    char * inpPtr;
    cout << "Give me a string please" << endl;
    cin.getline(input,maxLen);
    
    inpPtr = input;
    
    while (*inpPtr)  // While not string terminator
      letters[Letters(*inpPtr++)]++;  // !!! Guess what this does !!!  
    
    cout << "Your string contains: " << endl;
    cout << "Non-alpha " << letters[0] << endl;
    for (int i = 1; i < 27; i++)
      if (letters[i])
        cout << (char)('A' + i - 1) << "         "
             << letters[i] << endl;
  }

C++ From Year 1995 Extras

 // Filename: BIT1.CPP

// Demonstrate &, |, ^, and ~ on two values

#include <iostream.h>

void main()

{

  int i = 5, j = 12;

  int answer;

  // Although this program applies the bitwise operators to

  // variables, bitwise operators also work on literal values


  answer = i & j;

  cout << "The result of i & j is " << answer << endl;


  answer = i | j;

  cout << "The result of i | j is " << answer << endl;


  answer = i ^ j;

  cout << "The result of i ^ j is " << answer << endl;


  // Notice how ~ takes only a single argument

  answer = ~i;

  cout << "The result of ~i is " << answer << endl;

  answer = ~j;

  cout << "The result of ~j is " << answer << endl;


  return;

}

===========================

// Filename: BITEQUI2.CPP

// Uses bitwise operators to work with user input

#include <iostream.h>

void main()

{

  int i, result;

  char c;


  cout << "Enter a number and I'll say if it's odd or even: ";

  cin >> i;


  if (i & 1)

    { cout << "The number is odd" << endl; }

  else

    { cout << "The number is even" << endl; }


  cout << endl << "Enter a number that you want multiplied by 32: ";

  cin >> i;

  result = i << 5;  // Multiplies by 2 raised to the 5th power

  cout << i << " times 32 is " << result << endl;


  result = i >> 3;

  cout << i << " divided by 8 is " << result << endl;


  cout << endl << "Please enter your first initial: ";

  cin >> c;

  if (c & 32)

    { cout << "Always type your initial in uppercase" << endl; }

  else

    { cout << "You entered the initial in uppercase, good!" << endl; }


  return;

}

========================

// Filename: BITEQUIV.CPP

// Uses bitwise operators to work with user input

#include <iostream.h>

void main()

{

  int i, result;

  char c;


  cout << "Enter a number and I'll say if it's odd or even: ";

  cin >> i;


  if ((i & 1) == 1)

    { cout << "The number is odd" << endl; }

  else

    { cout << "The number is even" << endl; }


  cout << endl << "Enter a number that you want multiplied by 32: ";

  cin >> i;

  result = i << 5;   // Multiply by 2 raised to the fifth power

  cout << i << " times 32 is " << result << endl;


  cout << endl << "Please enter your first initial: ";

  cin >> c;

  if (c & 32)

    { cout << "Always type your initial in uppercase" << endl; }

  else

    { cout << "You entered the initial in uppercase, good!" << endl; }


  return;

}

=========================

// Filename: BITSHIFT.CPP

// Shows the results of several bitwise shift operations

#include <iostream.h>

void main()

{

  int shiftResult;


  shiftResult = 13 << 2;

  cout << "13 << 2 is " << shiftResult << endl;


  shiftResult = 13 >> 2;

  cout << "13 >> 2 is " << shiftResult << endl;


  shiftResult = -13 << 2;

  cout << "-13 << 2 is " << shiftResult << endl;


  shiftResult = -13 >> 2;

  cout << "-13 >> 2 is " << shiftResult << endl;


  return;

}

======================

// Filename: BONUSP1.CPP

// Shows how the advanced operators give

// you more control and efficiency

#include <iostream.h>


const int MAKEUPPER = 223;


void main()

{

  char partCode;

  int num, doubleNum;

  float price;

  double totalInv;


  cout << "** Inventory Valuation **" << endl << endl;

  cout << "What is the character part code? ";

  cin >> partCode;

  

  partCode &= MAKEUPPER;   // Ensure that the part

                           // code is uppercase


  cout << "How many parts are there? ";

  cin >> num;

  cout << "What is the price of each part? ";

  cin >> price;


  cout.precision(2);

  cout.setf(ios::showpoint);

  cout.setf(ios::fixed);

  totalInv = (double)num * (double)price;

  cout << endl << "For part code " << partCode << ", ";

  cout << "the total valuation is $" << totalInv << endl;


  doubleNum = num << 1;   // Compute double the current number

  cout << endl << "Doubling our inventory would give us "

       << doubleNum << " new parts" << endl;

  (num < 20) ? cout << endl << "We need to order more inventory!" 

                    << endl

             :

               cout << endl << "We now have enough inventory"

                    << endl;

 }

================

// Filename: ORANGE.CPP

// See if the user likes orange juice

#include <iostream.h>


void main()

{

  const int UPMASK = 223;

  char ans;


  cout << "Do you like fresh squeeze orange juice (Y/N)? ";

  cin >> ans;


  ans &= UPMASK;  // Convert to uppercase

  if (ans == 'Y')

    { cout << "You'll be healthy all your life!" << endl; }

  else

    { cout << "You need the vitamin C!" << endl; }


  return;

}