Author Topic: Programming Megathread  (Read 107710 times)

For my security class where we need to defend and attack computers we're using debian. I needed to make my own installation media for it, I'm pretty sure I forgeted up a jump drive real good. I can't find it anywhere in device manager or anything. I made another one that worked but now it's not recognized as media but atl east it still shows up and it works.

so I'm doing visual studio coding at school and today we were asked to make our own function

Code: [Select]
Public Class Form1
    Dim variableA As String
    Dim variableB As String

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        variableA = InputBox("Enter a number")
        variableB = Generate(variableA)

    End Sub

    Function Generate(ByVal variableA As String, ByRef variableB As String)
        variableB = Len(variableA)
        variableB = UCase(variableA)

        Return variableB
    End Function
End Class

the problem is though is the variableB = Generate(variableA) part, it keeps saying

I'm not really sure what it means, I'm just trying to call my function on variableA

EDIT: fixed it by mending Function Generate(ByVal variableA As String, ByRef variableB As String) to Function Generate(ByVal variableA As String) but now I'm having trouble with global and local variables, it works though
« Last Edit: January 26, 2016, 06:01:37 PM by Maxwell. »


but now I'm having trouble with global and local variables
Like what

Like what
well the code doesn't need any global variables, I'm just trying to get it so it uses local variables only because it's seen as bad practise idk

I mean like this


You can change the size of the command prompt window

Keep the invalid reasons coming bb

You can change the size of the command prompt window
yes, I know. do you know what default means? because I do, that's why I said it

yes, I know. do you know what default means? because I do, that's why I said it
Oh, you didn't realize that I'm responding to your terrible reasoning with a little less terrible reasons? There's no valid reason to keep an 80 character limit.

well the code doesn't need any global variables, I'm just trying to get it so it uses local variables only because it's seen as bad practise idk
They're not technically global, they're members of the class "Form1"
Just pass variableB as the second argument to Generate(A, B)?
Also returning B doesn't accomplish anything useful if it's ByRef
« Last Edit: January 26, 2016, 06:54:18 PM by Headcrab Zombie »

They're not technically global, they're members of the class "Form1"
Just pass variableB as the second argument to Generate(A, B)?
Also returning B doesn't accomplish anything useful if it's ByRef
yeah IK, I've fixed it up now
Code: [Select]
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim variableA As String = InputBox("Enter a name")
        Dim variableGA As String

        variableGA = Generate(variableA)

        lblName.Text = variableGA
    End Sub

    Function Generate(ByVal variableA As String)
        Return Len(variableA) & UCase(variableA)
    End Function
End Class

So I'm working on some simple java project for class just to get situated with it again after winter break. I'm trying to traverse a string so that if there is a certain character at any position it gets pushed to a stack. Now I am having trouble with using charAt for some reason. My string is called str and whenever I try calling str.charAt[z] I'm always getting this error:
Code: [Select]
cannot find symbol
if (str.charAt[z] == '(' )
(Then it points to the . between str and charAt)
symbol: variable charAt
location: variable str of type string

I'm guessing I'm not using charAt correctly? Like I said it's been a month since I've done java.

So I'm working on some simple java project for class just to get situated with it again after winter break. I'm trying to traverse a string so that if there is a certain character at any position it gets pushed to a stack. Now I am having trouble with using charAt for some reason. My string is called str and whenever I try calling str.charAt[z] I'm always getting this error:
Code: [Select]
cannot find symbol
if (str.charAt[z] == '(' )
(Then it points to the . between str and charAt)
symbol: variable charAt
location: variable str of type string

I'm guessing I'm not using charAt correctly? Like I said it's been a month since I've done java.
No, you're using it correctly from what I can see here... Can you post the rest of your code?

Code: [Select]
String str = scan.next();
for (int i = 0; i < str.length(); i++)
if (str.charAt[i] == '(' )
stackVaribleName.push(str.charAt[i]);
This will also give me the same error at the last line.

Code: [Select]
String str = scan.next();
for (int i = 0; i < str.length(); i++)
if (str.charAt[i] == '(' )
stackVaribleName.push(str.charAt[i]);
This will also give me the same error at the last line.
Surely that's not the rest of the code... Can you just copy-paste it? Sometimes errors don't actually come from where the compiler tells you they do.

Sorry, I'm writing it through a putty console to my school's linux server, or else I would have posted the whole thing right then. Give me one moment though.
Code: [Select]
import java.util.Scanner;
public class StackTester
{
CharStack testStack = new CharStack();
Scanner scan = new Scanner(System.in);
System.out.println("Please enter a string:");
String str = scan.next();

for (int i = 1; i < str.length(); i++)
if (str.charAt[i] == '(')
testStack.push(str.charAt[i]);
}//main
« Last Edit: January 26, 2016, 09:35:06 PM by Legodude77 »