By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

Saving Location and Size to Text Fiels into Database

P: n/a
Hi all,
I have a simple problem but I don't know which is the best way to
solve it.
I need to savo into a table into access DB the location and the size
of a form.
Is there a way to save Location and Size into a single text field, on
I need 4 Field X,Y,Height and Width?
If yes, how can convert Location and Size into String and then Back to
a Location and Size to apply back to the form?

Many Thanks
Jun 27 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On May 27, 11:10 pm, Marcolino <marco.pozzu...@gmail.comwrote:
Hi all,
I have a simple problem but I don't know which is the best way to
solve it.
I need to savo into a table into access DB the location and the size
of a form.
Is there a way to save Location and Size into a single text field, on
I need 4 Field X,Y,Height and Width?
If yes, how can convert Location and Size into String and then Back to
a Location and Size to apply back to the form?

Many Thanks
Hi,
Sure it's possible. Forms have "location" and "size" property and you
can get them as strings.

' Assign size/location of current form to strings
Dim X As String = Me.Location.X.ToString()
Dim Y As String = Me.Location.Y.ToString
Dim width As String = Me.Size.Width.ToString
Dim height As String = Me.Size.Height.ToString

' And your string variables are ready to be recorded into your
database.

...and when you want to apply them after retrieving from your
database, simply set these properties from db's in form's load event.
Thanks,

Onur Güzel
Jun 27 '08 #2

P: n/a
You can construct a system.drawing.point from the x and y co-ordinates so
you could save them as either a single string or as two seperate fields. I
would save each as a seperate field as it would be easier to report upon.

However, if you want to store them as two strings (or one string) the code
below shows how to reconstruct the system.drawing.point from a comma
seperated string.

Kind regards,

Rob
Code follows:

Dim sLocation As String = ""

sLocation = Me.Location.X.ToString + "," + Me.Location.Y.ToString

Me.Location = New System.Drawing.Point(0, 0)
MsgBox("moved")

Me.Location = New System.Drawing.Point(Split(sLocation, ",")(0),
Split(sLocation, ",")(1))
MsgBox("moved back")

"Marcolino" <ma************@gmail.comwrote in message
news:1c**********************************@2g2000hs n.googlegroups.com...
Hi all,
I have a simple problem but I don't know which is the best way to
solve it.
I need to savo into a table into access DB the location and the size
of a form.
Is there a way to save Location and Size into a single text field, on
I need 4 Field X,Y,Height and Width?
If yes, how can convert Location and Size into String and then Back to
a Location and Size to apply back to the form?

Many Thanks
Jun 27 '08 #3

P: n/a
On 27 Mag, 22:36, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On May 27, 11:10 pm, Marcolino <marco.pozzu...@gmail.comwrote:
Hi all,
I have a simple problem but I don't know which is the best way to
solve it.
I need to savo into a table into access DB the location and the size
of a form.
Is there a way to save Location and Size into a single text field, on
I need 4 Field X,Y,Height and Width?
If yes, how can convert Location and Size into String and then Back to
a Location and Size to apply back to the form?
Many Thanks

Hi,
Sure it's possible. Forms have "location" and "size" property and you
can get them as strings.

' Assign size/location of current form to strings
Dim X As String = Me.Location.X.ToString()
Dim Y As String = Me.Location.Y.ToString
Dim width As String = Me.Size.Width.ToString
Dim height As String = Me.Size.Height.ToString

' And your string variables are ready to be recorded into your
database.

...and when you want to apply them after retrieving from your
database, simply set these properties from db's in form's load event.

Thanks,

Onur Güzel
Thanks for your suggestion,
I know this way, but i need 4 field into Database, but in this case I
have only 2 fields, one for location and one for size.
My question is is there a way to put location into database using only
one field and then convert back.

Thanks
Jun 27 '08 #4

P: n/a
On May 28, 12:01 am, Marcolino <marco.pozzu...@gmail.comwrote:
On 27 Mag, 22:36, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On May 27, 11:10 pm, Marcolino <marco.pozzu...@gmail.comwrote:
Hi all,
I have a simple problem but I don't know which is the best way to
solve it.
I need to savo into a table into access DB the location and the size
of a form.
Is there a way to save Location and Size into a single text field, on
I need 4 Field X,Y,Height and Width?
If yes, how can convert Location and Size into String and then Back to
a Location and Size to apply back to the form?
Many Thanks
Hi,
Sure it's possible. Forms have "location" and "size" property and you
can get them as strings.
' Assign size/location of current form to strings
Dim X As String = Me.Location.X.ToString()
Dim Y As String = Me.Location.Y.ToString
Dim width As String = Me.Size.Width.ToString
Dim height As String = Me.Size.Height.ToString
' And your string variables are ready to be recorded into your
database.
...and when you want to apply them after retrieving from your
database, simply set these properties from db's in form's load event.
Thanks,
Onur Güzel

Thanks for your suggestion,
I know this way, but i need 4 field into Database, but in this case I
have only 2 fields, one for location and one for size.
My question is is there a way to put location into database using only
one field and then convert back.

Thanks
Sorry if i misunderstood you, so you want to store location's X and Y
in a single string?

Then, would you mind concentrating size's height and width into one
string variable?

' To store
Dim location As String
location = "X:" & Me.Location.X & " " & "Y:" & Me.Location.Y
Thanks,

Onur Güzel
Jun 27 '08 #5

P: n/a
On May 28, 12:19 am, kimiraikkonen <kimiraikkone...@gmail.comwrote:

Then, would you mind concentrating size's height and width into one
string variable?

Sorry for my mistype, i meant:
"Then, would you mind concentrating location's X and Y into one
string variable?"

..and it's clear what i meant from the code :)

Thanks,

Onur Güzel
Jun 27 '08 #6

P: n/a
On 27 Mag, 22:55, "Rob Blackmore" <r...@robblackmore.comwrote:
You can construct a system.drawing.point from the x and y co-ordinates so
you could save them as either a single string or as two seperate fields. *I
would save each as a seperate field as it would be easier to report upon.

However, if you want to store them as two strings (or one string) the code
below shows how to reconstruct the system.drawing.point from a comma
seperated string.

Kind regards,

Rob

Code follows:

* * * * Dim sLocation As String = ""

* * * * sLocation = Me.Location.X.ToString + "," + Me.Location.Y..ToString

* * * * Me.Location = New System.Drawing.Point(0, 0)
* * * * MsgBox("moved")

* * * * Me.Location = New System.Drawing.Point(Split(sLocation, ",")(0),
Split(sLocation, ",")(1))
* * * * MsgBox("moved back")

"Marcolino" <marco.pozzu...@gmail.comwrote in message

news:1c**********************************@2g2000hs n.googlegroups.com...
Hi all,
I have a simple problem but I don't know which is the best way to
solve it.
I need to savo into a table into access DB the location and the size
of a form.
Is there a way to save Location and Size into a single text field, on
I need 4 Field X,Y,Height and Width?
If yes, how can convert Location and Size into String and then Back to
a Location and Size to apply back to the form?
Many Thanks- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
Hi Rob,
following your suggestion i created this 4 function that do excatly
what i need.
Bye

Public Function LocationToString(ByVal l As Point) As String
Trace("", "Location=" & l.ToString)
Return l.X.ToString & ";" & l.Y.ToString
End Function

Public Function LocationFromString(ByVal s As String) As Point
Trace("", "Location=" & s)
LocationFromString.X = Split(s, ";")(0)
LocationFromString.Y = Split(s, ";")(1)
End Function

Public Function SizeToString(ByVal s As Size) As String
Trace("", "Size=" & s.ToString)
Return s.Width.ToString & ";" & s.Height.ToString
End Function

Public Function SizeFromString(ByVal s As String) As Size
Trace("", "Size=" & s)
SizeFromString.Width = Split(s, ";")(0)
SizeFromString.Height = Split(s, ";")(1)
End Function
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.