Silkroad Online Forums

A community forum for the free online game Silkroad Online. Discuss Silkroad Online, read up on guides, and build your character and skills.

Faq Search Members Chat  Register Profile Login

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Visual Basics
PostPosted: Tue Oct 16, 2012 8:13 am 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
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.

this code works fine

Code:
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

Quote:
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.

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Thu Oct 18, 2012 12:52 am 
Addicted Member
User avatar
Offline

Joined: Apr 2008
Posts: 2612
Location: Texas
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Thu Oct 18, 2012 11:16 am 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
im new to coding whats that mean?

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Thu Oct 18, 2012 8:03 pm 
Active Member
User avatar
Offline

Joined: Sep 2007
Posts: 895
Location:
Oasis
I don't know which version of visual basic you have (I've only used VB6 :() nor am I great at programming...

So in VB6 there is no such thing as a .value property for textboxes but maybe your problem is that, that property doesn't support decimals?

Sorry can't help much but I know someone will be able to help :D

_________________
Silkroad Online.
Server:Venus
IGN:KrazyStrong
Level:78
Build:Warrior
Guild:SuddenDeath

Image


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Thu Oct 18, 2012 11:48 pm 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
ShiningBow wrote:
I don't know which version of visual basic you have (I've only used VB6 :() nor am I great at programming...

So in VB6 there is no such thing as a .value property for textboxes but maybe your problem is that, that property doesn't support decimals?

Sorry can't help much but I know someone will be able to help :D


the box its refering to is
html
<input id="txtcels" type="text" />

but if it dont support decimals how can i work around that the decimal isnt all that important -275 will do but that dont work either.

atm i dont know where iv put my usb stick with this on, iv not been backing up as its not actual important work...wish i had now

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Fri Oct 19, 2012 4:21 am 
Senior Member
User avatar
Offline

Joined: Oct 2006
Posts: 4236
Location: CS:GO
Does the code compile? Does it give you an error message? If it does compile, what is the problem with it?

_________________
ImageCrumpets for PresImage


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Fri Oct 19, 2012 9:42 am 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
there are no error messages with it as i said when i use 0 the code works i dont know it might work with positive numbers

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Thu Oct 25, 2012 10:45 pm 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
Urgent I am getting fustrated so please help

i must be terrible at coding this fraction calculator wont work at all and i dont know why
Code:
<html>
    <head>
        <title></title>
    </head>
    <body>
        <center>
            <p>Fraction A...............................Fraction B................................Answer</p>
            <input id="txtnum1" type="text" />+<input id="txtnum2" type="text" />=<input id="txtnum3" type="text" /></br>
            <input id="txtden1" type="text" />+<input id="txtden2" type="text" />=<input id="txtden3" type="text" /></br>
            <input id="btncalc" type="button" value="Calculate" /><input id="btnsimp" type="button" value="simplify" />
        </center>       
    </body>
</html>

<script language="vbscript">

sub btncalc_onclick()

    txtnum3.value = cint(txtnum1.value * txtden2.value) + cint(txtnum2.value * txtden1.value)
    txtden3.value = txtden1.value * txtden2.value


end sub

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

</script>

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject: Re: Visual Basics
PostPosted: Thu Oct 25, 2012 11:13 pm 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
triple post the problematic code is
Code:

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

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group