How to fix the TextField?

 HStack {Text("Calculated number"); TextField("", value: $calculated, format: .number) }
            HStack {Text("Calculate number"); TextField("", value: $calculator, format: .number) }
            HStack {Text("Calculate way"); TextField("", value: $calculateway, format: .number)}

For the code above, Xcode will show error: Can't find $calculated, $calculator and $calculateway. How to solve this error?

Also I want to create a Label that shows word:'Result:'and a variable called calresult but I don't know how to make the Label, can anyone give me the code to create the Label I said? I hope the Label will show these text, (calresult)means the data in calresult: Result: (calresult)

You show just part of code.

How did you declare calculator and calculated ?

It must be declared inside the struct ContentView as

@State private var  calculator = 0.0
@State private var  calculated = 0.0

Here is the whole code @Claude31

import SwiftUI
public var calculated = 0.0
public var calculator = 0.0
public var calculateway = ""
struct Panel: View {
    var body: some View {
        VStack {
            Image(systemName: "person")
                .imageScale(.large)
                .foregroundColor(.red)
            HStack {Text("Calculated number"); TextField("", value: $calculated, format: .number) }
            HStack {Text("Calculate numebr"); TextField("", value: $calculator, format: .number) }
            HStack {Text("Calculate way"); TextField("", value: $calculateway, format: .number)}
        }
    }
}
public var calresult = 0.0
public func calculate() {
    if calculateway == "+" {
        calresult = Double(Float(calculated + calculator))
    }
    else if calculateway == "-" {
        calresult = Double(Float(calculated - calculator))
    }
    else if calculateway == "*" {
        calresult = Double(Float(calculated * calculator))
    }
    else if calculateway == "x" {
        calresult = Double(Float(calculated * calculator))
    }
    else if calculateway == "X" {
        calresult = Double(Float(calculated * calculator))
    }
    else if calculateway == "divided by" {
        calresult = Double(Float(calculated / calculator))
    }
}
struct Result: View {
    var body: some View {
        VStack {
            Label("Result:", systemImage: /*@START_MENU_TOKEN@*/"42.circle"/*@END_MENU_TOKEN@*/)
                .labelStyle(.titleOnly)
        }
     }
}
How to fix the TextField?
 
 
Q