Is there a way to simplify this?
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Is there a way to simplify this code?
Thanks!
Code: Select all
I want to set the value of valueBoard to an integer array with a specified width and height and have all values set to zero. Sub New(ByVal width As Integer, ByVal height As Integer)
Dim result(width, height) As Integer
valueBoard = result
End Sub
Thanks!
This is already simple and I am not sure exactly what you wanted. Is this what you want?
Code: Select all
That is the same as what you have but it's using arrays instead of integersPublic ValueBoard As Array
Public Sub Example(ByVal width As Array, ByVal height As Array)
Dim result() As Array = {width, height}
ValueBoard = result
width = {0}
height = {0}
result = {width, height}
End Sub
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
I'm wondering if there is a way to put everything in the sub on one line instead of two. It seems like there should be a way, but I don't know how...
I cannot figure out a way to put your code into one line though it doesn't mean it is impossible. Maybe need to try something completely different. Sorry I couldn't help though if I come up with something I'll be sure to let you know.
EDIT:
You're allowed to set valueBoard's value like this:
EDIT:
You're allowed to set valueBoard's value like this:
Code: Select all
But you still need to set the values back to 0 like you wanted but your first two lines are now one.Public valueBoard As Integer
Public Sub Example(ByVal width As Integer, ByVal height As Integer)
Dim result(width, height) As Integer, valueboard = result(width, height)
End Sub
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023