Dim pH, concH, MpH As Double
Dim Matcher1 As Matcher
'Generates a random pH problem for A2 level pupils, maybe two, If I have a mind to do a strong acid AND a weak one.
pH = Rnd(0,685) + 12
pH = NumberFormat(pH/100,1,3) 'a pH value between 0.12 and 6.97
MpH = -(pH)
concH = Power(10, MpH)
Dim strVar() As String=Regex.Split("E",concH)
Label1.Text = "For a strong acid, e.g. HCl:"
Label2.Text = "pH = " & pH
Matcher1 = Regex.Matcher("E", concH)
If Matcher1.Find Then
Label3.Text = "[H+] = " & NumberFormat(strVar(0),1,3) & "E" & strVar(1)
Else
Label3.Text = "[H+] = " & NumberFormat(strVar(0),1,6)
End If