473,729 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET App: store a value in vb.net at run time

karthickbabu
33 New Member
Is Possible to store a value to declared Variable from Text Box at run time. I want to store a value from Text Box in 2 dimension array. First Value can be sotred in variable(0,0). If i press enter text box will be cleared and get another number and it stored in variable(0,1) and so on

I try like this, but not working any problem in this code
Expand|Select|Wrap|Line Numbers
  1.          For i As Integer = 0 To 1
  2.               For j As Integer = 0 To 1
  3.                    FirstMatrixArray(i, j) = Val(txtInput.Text)
  4.                        txtInput.Text = ""
  5.                        txtInput.Focus()
  6.                    End If
  7.                Next
  8.          Next 
  9.  
Let me know your idea about this

Hope your reply
Dec 3 '07 #1
4 2766
CyberSoftHari
487 Recognized Expert Contributor
The code you done will update the 2d array every time you trigger the enter.
1. Give i and j declaration as private in that class.
2. Increment i and j value after enter press (in key press event).
3. write assignment statement for FirstMatrixArra y(i, j) in key press event after FirstMatrixArra y index changed.
Dec 3 '07 #2
karthickbabu
33 New Member
I tried all possible ways. But i couldnt get anything. Let me give any example it will help to me.

The code you done will update the 2d array every time you trigger the enter.
1. Give i and j declaration as private in that class.
2. Increment i and j value after enter press (in key press event).
3. write assignment statement for FirstMatrixArra y(i, j) in key press event after FirstMatrixArra y index changed.
Dec 6 '07 #3
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
use variables i and j in the class (class variables)

and use the button click event (users hits enter / clicks the button to submit the value)

set i and j to 0 on the load of the form.

Expand|Select|Wrap|Line Numbers
  1. int i = 0, j = 0;
  2. int maxi = 2, maxj = 2;
  3. int[,] matrixArr = new int[maxi,maxj];
  4.  
  5. private void btnSubmitValue_Click(object sender,  EventArgs e)
  6. {
  7.    this.matrixArr[i,j] = this.txtInput.Text;
  8.    j++;
  9.    if(j >= this.maxj)
  10.    {
  11.        j = 0;
  12.        i++;
  13.    }
  14.    if(i >= this.maxi)
  15.    {
  16.        //array has been filled if it reaches this line
  17.        this.txtInput.Enabled = false;
  18.        this.btnSubmit.Enabled = false;
  19.    }
  20. }
I have used an online converter to convert it to vb .net, but havent tested it

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer =  0,j As Integer =  0 
  2. Dim maxi As Integer =  2,maxj As Integer =  2 
  3. Dim matrixArr(,) As Integer =  New Integer(maxi,maxj) {} 
  4.  
  5. Private  Sub btnSubmitValue_Click(ByVal sender As Object, ByVal e As EventArgs)
  6.    Me.matrixArr(i,j) = Me.txtInput.Text
  7.    j = j + 1
  8.    If j >= Me.maxj Then
  9.        j = 0
  10.        i = i + 1
  11.    End If
  12.    If i >= Me.maxi Then
  13.        'array has been filled if it reaches this line
  14.        Me.txtInput.Enabled = False
  15.        Me.btnSubmit.Enabled = False
  16.    End If
  17. End Sub
Dec 6 '07 #4
karthickbabu
33 New Member
Hi
Thanks I got some ideas from your code. I will try this code. Surely it will be help to me. I reply after i test this code with my code

Once again thanks



use variables i and j in the class (class variables)

and use the button click event (users hits enter / clicks the button to submit the value)

set i and j to 0 on the load of the form.

Expand|Select|Wrap|Line Numbers
  1. int i = 0, j = 0;
  2. int maxi = 2, maxj = 2;
  3. int[,] matrixArr = new int[maxi,maxj];
  4.  
  5. private void btnSubmitValue_Click(object sender,  EventArgs e)
  6. {
  7.    this.matrixArr[i,j] = this.txtInput.Text;
  8.    j++;
  9.    if(j >= this.maxj)
  10.    {
  11.        j = 0;
  12.        i++;
  13.    }
  14.    if(i >= this.maxi)
  15.    {
  16.        //array has been filled if it reaches this line
  17.        this.txtInput.Enabled = false;
  18.        this.btnSubmit.Enabled = false;
  19.    }
  20. }
I have used an online converter to convert it to vb .net, but havent tested it

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer =  0,j As Integer =  0 
  2. Dim maxi As Integer =  2,maxj As Integer =  2 
  3. Dim matrixArr(,) As Integer =  New Integer(maxi,maxj) {} 
  4.  
  5. Private  Sub btnSubmitValue_Click(ByVal sender As Object, ByVal e As EventArgs)
  6.    Me.matrixArr(i,j) = Me.txtInput.Text
  7.    j = j + 1
  8.    If j >= Me.maxj Then
  9.        j = 0
  10.        i = i + 1
  11.    End If
  12.    If i >= Me.maxi Then
  13.        'array has been filled if it reaches this line
  14.        Me.txtInput.Enabled = False
  15.        Me.btnSubmit.Enabled = False
  16.    End If
  17. End Sub
Dec 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3291
by: Chris Dunaway | last post by:
A quick scan of the group did not immediately reveal an answer to my questions so here goes. First let me describe my app and then I'll ask the questions. I am writing a Windows Forms App (not Web Forms) that serves as a thin client to some web services. In other words, the Windows Forms app will be installed on the client machines and that app will call web services that are deployed on my server.
33
3045
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have been for years. If the machine has memory to spare and windows can use it - I'm thinking "Why not?" I was wondering what some of you have to say about that, particularly any severe "gotchas" you've had the unfortunate experience to contend with.
7
2918
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
3
602
by: Tim Gallivan | last post by:
Hi all, I think read somewhere (but I can't find it ... note to self: must get new filing system ...) that there is a workaround so that an app.config can have multiple keys with the same name or something of the like. What I require is the ability to point at a development or live database without changing any existing code in my multiple DLL / single form project. <add key="dtacollect.ConnectionString"...
2
4056
by: Dotnet Gruven | last post by:
Hi, If a server is physically localled in CST and is shared, how can one create a Web Application on that server that has its timezone for EST??? I've seen other threads in this group that talk about using UTC/GMT and also getTimezoneOffset(), but in this case, the business rules are such that the Web App be based upon the time zone that the physical business is located. TIA,
10
3667
by: Brett Romero | last post by:
I'd like to store something such as the following the my app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="DEBUG" value="true"/> <add key="DEBUGCleanFile" value="true"/> </appSettings>
6
1424
by: NickP | last post by:
Hi there, I am implementing a simple "/U" command line argument for a .NET application that instructs the application to delete the following folders... My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData The application deletes these folders successfully then exits. Even
8
16095
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list which modifies Application setting section but how to add new item to userSettings ? Andrus.
3
9745
by: =?Utf-8?B?Sm9u?= | last post by:
Hello, I have tried to use the app.config and settings.cs files to store my data (which I want to be user changeable at runtime). I can write to (what I assume is an object in memory) and it does seem to work...however, once the application is closed and reopened the changes are lost. How do I persist the information? Here is some sample code using both methods: //////Using Properties.Settings///////
0
8921
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8763
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.