Saving Location and Size to Text Fiels into Database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcolino

    Saving Location and Size to Text Fiels into Database

    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
  • kimiraikkonen

    #2
    Re: Saving Location and Size to Text Fiels into Database

    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.T oString()
    Dim Y As String = Me.Location.Y.T oString
    Dim width As String = Me.Size.Width.T oString
    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

    Comment

    • Rob Blackmore

      #3
      Re: Saving Location and Size to Text Fiels into Database

      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.T oString + "," + Me.Location.Y.T oString

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

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

      "Marcolino" <marco.pozzuolo @gmail.comwrote in message
      news:1c28386c-80bc-434a-a65b-297900c30271@2g 2000hsn.googleg roups.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

      Comment

      • Marcolino

        #4
        Re: Saving Location and Size to Text Fiels into Database

        On 27 Mag, 22:36, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
        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.T oString()
        Dim Y As String = Me.Location.Y.T oString
        Dim width As String = Me.Size.Width.T oString
        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

        Comment

        • kimiraikkonen

          #5
          Re: Saving Location and Size to Text Fiels into Database

          On May 28, 12:01 am, Marcolino <marco.pozzu... @gmail.comwrote :
          On 27 Mag, 22:36, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
          >
          >
          >
          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.T oString()
          Dim Y As String = Me.Location.Y.T oString
          Dim width As String = Me.Size.Width.T oString
          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

          Comment

          • kimiraikkonen

            #6
            Re: Saving Location and Size to Text Fiels into Database

            On May 28, 12:19 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:

            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

            Comment

            • Marcolino

              #7
              Re: Saving Location and Size to Text Fiels into Database

              On 27 Mag, 22:55, "Rob Blackmore" <r...@robblackm ore.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.T oString + "," + Me.Location.Y.. ToString
              >
                      Me.Location = New System.Drawing. Point(0, 0)
                      MsgBox("moved")
              >
                      Me.Location = New System.Drawing. Point(Split(sLo cation, ",")(0),
              Split(sLocation , ",")(1))
                      MsgBox("moved back")
              >
              "Marcolino" <marco.pozzu... @gmail.comwrote in message
              >
              news:1c28386c-80bc-434a-a65b-297900c30271@2g 2000hsn.googleg roups.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 LocationToStrin g(ByVal l As Point) As String
              Trace("", "Location=" & l.ToString)
              Return l.X.ToString & ";" & l.Y.ToString
              End Function

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

              Public Function SizeToString(By Val s As Size) As String
              Trace("", "Size=" & s.ToString)
              Return s.Width.ToStrin g & ";" & s.Height.ToStri ng
              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

              Comment

              Working...