Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Using variables in one form in another


  • Please log in to reply
6 replies to this topic

#1 rajjaak24

rajjaak24

  • Members
  • 46 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:05 PM

Posted 11 August 2013 - 09:48 AM

Hi,

 

I'm creating something where a person searches for something and the results are shown as images which can then be saved or "uploaded". To "upload" the image to my server I created a new form with a web browser. My server utilises and API to upload images with a link so my goal is something like this:

if listview1.highlight = true then
 
webbrowser1.navigation("http://API.COM/?= * ") 
 
end if

the * represents the original image link. My first problem is that form2 doesn't recognise listview1 because its declared in form1. How would I go about using the form1 variable in form2 without mass copy and paste. My second issue is getting the original URL, as in how do I tell VB that "I want you to copy the address of the highlighted image and load it here".

 

I did some googling prior to making this post, but I found it rather confusing, the code was just handed to me with no explanation on using it.

 

or better yet can this be done without form 2, so form1 creates a temporary form or something on that line...

 

Any help would be appreciated.


Edited by rajjaak24, 11 August 2013 - 09:50 AM.


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:05 PM

Posted 11 August 2013 - 10:01 AM

I did some googling prior to making this post, but I found it rather confusing, the code was just handed to me with no explanation on using it.

 

from a programming standpoint, are you in over your head? Passing values between forms is sort of a base function of any programming.

 

I'm creating something where a person searches for something and the results are shown as images which can then be saved or "uploaded"

You will probably find that you will get little help without specifics. You are showing us a couple of lines of code for an inderminate application, how can we possibly guess what your issue may be? Some specifics, with an actual example of how you are trying to use the code allows us to help without wasting our time. For all I know, you have built some hardware device that mounts on a bike, and allows you to browse photo albums whilst cruising skateparks and soda shops.

 

No context = no helpful responses.


Edited by groovicus, 11 August 2013 - 10:02 AM.
spleling


#3 Sirawit

Sirawit

    Bleepin' Brony


  • Malware Response Team
  • 4,162 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Thailand
  • Local time:02:05 AM

Posted 11 August 2013 - 10:37 AM

To use Variable across the form, you have to use this method:

form2_Variable = form1_variable

'like:

Form2.TextBox1.Text = formexchange

'This will load "formexchange" variable from form1 and display it in Textbox1 in form2.

You can replace Textbox with any public variables in form 2 with this method :

Form2.variable = formexchange

'When variable means any public variables in form2.

Note that formexachange variable is declared in Public state as string.

 

Thank you. Hope this helps you!


Edited by Sirawit, 11 August 2013 - 10:40 AM.

If I don't reply back to you in 2 days, feel free to send me a PM.

 

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.


#4 rajjaak24

rajjaak24
  • Topic Starter

  • Members
  • 46 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:05 PM

Posted 15 August 2013 - 02:47 AM

To use Variable across the form, you have to use this method:

form2_Variable = form1_variable

'like:

Form2.TextBox1.Text = formexchange

'This will load "formexchange" variable from form1 and display it in Textbox1 in form2.

You can replace Textbox with any public variables in form 2 with this method :

Form2.variable = formexchange

'When variable means any public variables in form2.

Note that formexachange variable is declared in Public state as string.

 

Thank you. Hope this helps you!

This is the sort of help I was looking for. I can work with this. 

 

Thank You!



#5 Sirawit

Sirawit

    Bleepin' Brony


  • Malware Response Team
  • 4,162 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Thailand
  • Local time:02:05 AM

Posted 15 August 2013 - 04:36 AM

No Problem! :)


If I don't reply back to you in 2 days, feel free to send me a PM.

 

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.


#6 ident

ident

  • Members
  • 109 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Cambridge
  • Local time:03:05 PM

Posted 17 August 2013 - 05:37 AM

A webbrowser is a UI element. You are not using it as such so do not use it. The Listview should be private so of course you should not be able to access it from another form. It's modifer is friend by default (why vb?). If you want to pass information then use the forms constructor.

 

Sirawit said the variables should be Public. With out sounding rude and i mean no disrespect this is lazy. They certainly should not be Public.


Edited by ident, 17 August 2013 - 05:46 AM.


#7 RobinHoodSnr

RobinHoodSnr

  • Members
  • 158 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:South Africa
  • Local time:09:05 PM

Posted 30 October 2013 - 09:36 AM

 For all I know, you have built some hardware device that mounts on a bike, and allows you to browse photo albums whilst cruising skateparks and soda shops

 

...lmao!

 

PS: no offence here folks...just had a little smile this side of the planet :)


Edited by RobinHoodSnr, 30 October 2013 - 09:38 AM.

...We all know something...but we will NEVER know everything :grinner:

 

Cryptlocker "Process" remover...will NOT delete Cryptolocker, only the processes...( a "safety precaution" I took for those who still want to "try" paying the ransom to get their files back. DON'T FORGET TO MONITOR YOUR TIME LEFT BEFORE PAYMENT! )

 

("KillCrypt" will automaticly open %appdatadir%...just guide this to Cryptolocker-Virus and double-click on it. Remember...if you "restart" your system, the processes will be back...use this only for emergencies if you want to create a quick document. While this processes is killed, your docs wont get infected, but WILL be encrypted (unusable) when you restart the PC/Laptop OR clicking on the Virus again!!!)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users