I keep getting the error 'send' was not declared in this scope

I keep getting the error 'send' was not declared in this scope
here is the code hope someone can help

#include <VirtualWire.h>

int  sensorAnalogPin = A0;    // Select the Arduino input pin to accept the Sound Sensor's analog output 
int  sensorDigitalPin = 3;    // Select the Arduino input pin to accept the Sound Sensor's digital output
int  analogValue = 0;         // Define variable to store the analog value coming from the Sound Sensor
int  digitalValue;            // Define variable to store the digital value coming from the Sound Senso

void setup()
{
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
    Serial.begin(9600);               // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
  pinMode(sensorDigitalPin,INPUT);  // Define pin 7 as an input port, to accept digital input
   
}

void loop()
{
    analogValue = analogRead(sensorAnalogPin); // Read the value of the analog interface A0 assigned to digitalValue 
  digitalValue=digitalRead(sensorDigitalPin); // Read the value of the digital interface 7 assigned to digitalValue 
  Serial.println(analogValue); // Send the analog value to the serial transmit interface
  
  if(analogValue>300)      // When the Sound Sensor sends signla, via voltage present, light LED13 (L)
  {
     
  send("Alarm went off");
  delay(1000);
}

void send (char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}

Try using the auto format tool in the IDE (Ctrl-T) as it will line up are your braces and indents and will reveal your problem.

I tried this but I am still getting this error

Of course you are. You didn't really change anything but the issue should be obvious. All of your code got indented because you are missing the closing } for the loop() function.

#include <VirtualWire.h>

int  sensorAnalogPin = A0;    // Select the Arduino input pin to accept the Sound Sensor's analog output
int  sensorDigitalPin = 3;    // Select the Arduino input pin to accept the Sound Sensor's digital output
int  analogValue = 0;         // Define variable to store the analog value coming from the Sound Sensor
int  digitalValue;            // Define variable to store the digital value coming from the Sound Senso

void setup()
{
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  Serial.begin(9600);               // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
  pinMode(sensorDigitalPin, INPUT); // Define pin 7 as an input port, to accept digital input

}

void loop()
{
  analogValue = analogRead(sensorAnalogPin); // Read the value of the analog interface A0 assigned to digitalValue
  digitalValue = digitalRead(sensorDigitalPin); // Read the value of the digital interface 7 assigned to digitalValue
  Serial.println(analogValue); // Send the analog value to the serial transmit interface

  if (analogValue > 300)   // When the Sound Sensor sends signla, via voltage present, light LED13 (L)
  {

    send("Alarm went off");
    delay(1000);
  }
// vvvvvvv--- strange indentation here
  void send (char *message)
  {
    vw_send((uint8_t *)message, strlen(message));
    vw_wait_tx(); // Wait until the whole message is gone
  }
#include <VirtualWire.h>

int  sensorAnalogPin = A0;    // Select the Arduino input pin to accept the Sound Sensor's analog output
int  sensorDigitalPin = 3;    // Select the Arduino input pin to accept the Sound Sensor's digital output
int  analogValue = 0;         // Define variable to store the analog value coming from the Sound Sensor
int  digitalValue;
void setup()
{
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  Serial.begin(9600);               // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
  pinMode(sensorDigitalPin, INPUT);
}

void loop()
{
  analogValue = analogRead(sensorAnalogPin); // Read the value of the analog interface A0 assigned to digitalValue
  digitalValue = digitalRead(sensorDigitalPin); // Read the value of the digital interface 7 assigned to digitalValue
  Serial.println(analogValue); // Send the analog value to the serial transmit interface

  if (analogValue > 300)   // When the Sound Sensor sends signla, via voltage present, light LED13 (L)
  {
    send("Hello, it's me");
    delay(1000);
  }

  void send (char *message)
  {
    vw_send((uint8_t *)message, strlen(message));
    vw_wait_tx(); // Wait until the whole message is gone
  }
}

I added it and it did nothing still getting that error

Your success depends greatly on where you added it. Was it before your send() function definition?

no I added it at the end

Hi @nuthead411
The send() function is inside the loop() function.
Test it now.

RV mineirin

#include <VirtualWire.h>

int  sensorAnalogPin = A0;    // Select the Arduino input pin to accept the Sound Sensor's analog output
int  sensorDigitalPin = 3;    // Select the Arduino input pin to accept the Sound Sensor's digital output
int  analogValue = 0;         // Define variable to store the analog value coming from the Sound Sensor
int  digitalValue;

void send (char *message)
{
    vw_send((uint8_t *)message, strlen(message));
    vw_wait_tx(); // Wait until the whole message is gone
}

void setup()
{
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  Serial.begin(9600);               // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
  pinMode(sensorDigitalPin, INPUT);
}

void loop()
{
  analogValue = analogRead(sensorAnalogPin); // Read the value of the analog interface A0 assigned to digitalValue
  digitalValue = digitalRead(sensorDigitalPin); // Read the value of the digital interface 7 assigned to digitalValue
  Serial.println(analogValue); // Send the analog value to the serial transmit interface

  if (analogValue > 300)   // When the Sound Sensor sends signla, via voltage present, light LED13 (L)
  {
    send("Hello, it's me");
    delay(1000);
  }
}

This topic would have been much shorter if you had quoted all of the actual error messages in the first post, instead of attempting to summarise them.