Iv just started learning vb in uni its not important i get this done now i can wait til next weeks lecture but i wanna mess around with some other stuff and its confusing me why this code isnt working.
sub btnkelv_onclick() If txtkelv.value < 0 Then fah.innertext = "Invalid" cels.innertext = "Invalid" Kelv.innertext = "Invalid" Else fah.innertext=txtkelv.value-273.15 cels.innertext=(((txtkelv.value-273.15)*9)/5)+32 kelv.innertext=txtkelv.value end if end sub
which basically is a calcualtor converting each temperature into different values but like i said this works perfect while this which is nearly identical code does not
sub btncels_onclick() If txtcels.value < -273.15 Then fah.innertext = "Invalid" cels.innertext = "Invalid" Kelv.innertext = "Invalid" Else cels.innertext=((txtcels.value*9)/5)+32 kelv.innertext=txtcels.value+273.15 fah.innertext=txtcels.value end if end sub
iv bolded the part that does not seem to work. i am simply trying to set a flaw value which it cannot go below as it does not exist.
Can't remember the last time I wrote code in VB, but perhaps define your flaw value as a constant instead of defining it directly in the condition and see what happens.
sub btnsimp_onclick() Dim GCD As Integer = GCF(txtnum3.value, txtden3.value) txtnum3.value = txtnum3.value / GCD txtden3.value = txtden3.value / GCD end sub
Function GCF(ByVal x As Integer, ByVal y As Integer) As Integer x = Math.Abs(x) y = Math.Abs(y) Dim z As Integer Do z = x Mod y If z = 0 Then Return y x = y y = z Loop End Function
sub btnsimp_onclick() Dim GCD As Integer = GCF(txtnum3.value, txtden3.value) txtnum3.value = txtnum3.value / GCD txtden3.value = txtden3.value / GCD end sub
Function GCF(ByVal x As Integer, ByVal y As Integer) As Integer x = Math.Abs(x) y = Math.Abs(y) Dim z As Integer Do z = x Mod y If z = 0 Then Return y x = y y = z Loop End Function
but i dont know why yet, il update this post in the future of my updates