Thank you a million!
The code now works
def test_form():
    def sub_function():
        st.session_state.mytexta
        st.session_state.mytextb
    
    with st.form("my_test_form_0", clear_on_submit = True):
        textA = st.text_input('Enter text A:',placeholder = 'enter here', key = 'mytexta')
        textB = st.text_input('Enter text B:',placeholder = 'enter here', key = 'mytextb')
        st.form_submit_button("Submit here!", on_click=sub_function)
def main():
    test_form()
main()