|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
empty GUID from string in VB2005When running this code in VB2003 Sub guidtest() Dim gstring As String Dim gid As Guid gstring = Guid.NewGuid().ToString gid = New Guid(gstring) End Sub variable GID gets the correct value derived from gstring - however when i do this in VB2005 it doesn't work - i just get an empty GUID - this seems like a fairly serious problem so i am assuming i have made some incorrect basic assumptions. my installation of VS2005 went pretty smoothly from memory and it pretty much has default options. Can anyone replicate this problem / error? is it a bug in VS/VB or .NET? I look forward to hearing from anyone with any ideas here as I have spent about 10 hours trying to see what I have done wrong. best Charles Charles,
Sorry however your code looks so strange in my eyes, probably you mean. \\\ dim gid as Guid = Guid.NewGuid dim gstring = gid.ToString /// Try to avoid using strings as intermediate, you see people do that as well with datetime. I hope this helps, Cor Hi,
No my code is intentionally trying to create a GUID from a string.. not the other way around. If I try the way you suggest it works fine - but that is not the problem I was trying to demonstrate. Thanks anyway. Charles Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23TpmqvgNGHA.2336@TK2MSFTNGP12.phx.gbl... > Charles, > > Sorry however your code looks so strange in my eyes, probably you mean. > > \\\ > dim gid as Guid = Guid.NewGuid > dim gstring = gid.ToString > /// > Try to avoid using strings as intermediate, you see people do that as well > with datetime. > > I hope this helps, > > Cor > > Charles,
I tried it in both now, It is working for me exactly the same. \\\ Dim gid As Guid = Guid.NewGuid Dim gid2 As Guid = New Guid(gid.ToString) /// Cor Hi,
I added this line after you created gid. MessageBox.Show(gstring, gid.ToString) I get the same value in the caption and text. Ken ------- Show quoteHide quote "Charles Hunt" <Char***@HuntRAD.NET> wrote in message news:OO7hmXgNGHA.2644@TK2MSFTNGP10.phx.gbl... > Hi, > > When running this code in VB2003 > > Sub guidtest() > > Dim gstring As String > > Dim gid As Guid > > gstring = Guid.NewGuid().ToString > > gid = New Guid(gstring) > > End Sub > > variable GID gets the correct value derived from gstring - however when i > do > this in VB2005 it doesn't work - i just get an empty GUID - this seems > like > a fairly serious problem so i am assuming i have made some incorrect basic > assumptions. > > my installation of VS2005 went pretty smoothly from memory and it pretty > much has default options. > > Can anyone replicate this problem / error? > > is it a bug in VS/VB or .NET? > > I look forward to hearing from anyone with any ideas here as I have spent > about 10 hours trying to see what I have done wrong. > > best > > Charles > > > Hi,
Which version of VB did you use? If I use VB2003 it works, if I use VB2005 it doesn't work. best Charles Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl... > Hi, > > I added this line after you created gid. > > MessageBox.Show(gstring, gid.ToString) > > I get the same value in the caption and text. > > > > Ken > ------- > "Charles Hunt" <Char***@HuntRAD.NET> wrote in message > news:OO7hmXgNGHA.2644@TK2MSFTNGP10.phx.gbl... >> Hi, >> >> When running this code in VB2003 >> >> Sub guidtest() >> >> Dim gstring As String >> >> Dim gid As Guid >> >> gstring = Guid.NewGuid().ToString >> >> gid = New Guid(gstring) >> >> End Sub >> >> variable GID gets the correct value derived from gstring - however when i >> do >> this in VB2005 it doesn't work - i just get an empty GUID - this seems >> like >> a fairly serious problem so i am assuming i have made some incorrect >> basic >> assumptions. >> >> my installation of VS2005 went pretty smoothly from memory and it pretty >> much has default options. >> >> Can anyone replicate this problem / error? >> >> is it a bug in VS/VB or .NET? >> >> I look forward to hearing from anyone with any ideas here as I have spent >> about 10 hours trying to see what I have done wrong. >> >> best >> >> Charles >> >> >> > > Hi,
hmmm.. actually that does work, but my original post demonstrates a problem where the gid object when inspected with a break point shows as "empty" - but the .tostring method does infact yield a correct value. This is a bit different in VB2003 because gid appears in the debugger correctly (or as expected) but not in VB2005 - where it shows up as "empty" - is it my installation or have I just made an abvious goof. best Charles Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl... > Hi, > > I added this line after you created gid. > > MessageBox.Show(gstring, gid.ToString) > > I get the same value in the caption and text. > > > > Ken > ------- > "Charles Hunt" <Char***@HuntRAD.NET> wrote in message > news:OO7hmXgNGHA.2644@TK2MSFTNGP10.phx.gbl... >> Hi, >> >> When running this code in VB2003 >> >> Sub guidtest() >> >> Dim gstring As String >> >> Dim gid As Guid >> >> gstring = Guid.NewGuid().ToString >> >> gid = New Guid(gstring) >> >> End Sub >> >> variable GID gets the correct value derived from gstring - however when i >> do >> this in VB2005 it doesn't work - i just get an empty GUID - this seems >> like >> a fairly serious problem so i am assuming i have made some incorrect >> basic >> assumptions. >> >> my installation of VS2005 went pretty smoothly from memory and it pretty >> much has default options. >> >> Can anyone replicate this problem / error? >> >> is it a bug in VS/VB or .NET? >> >> I look forward to hearing from anyone with any ideas here as I have spent >> about 10 hours trying to see what I have done wrong. >> >> best >> >> Charles >> >> >> > > "Charles Hunt" <Char***@HuntRAD.NET> schrieb You didn't write how you have it displayed in the IDE: Tooltip? Watch> Hi, > > hmmm.. actually that does work, but my original post demonstrates a > problem where the gid object when inspected with a break point shows > as "empty" - but the .tostring method does infact yield a correct > value. > > This is a bit different in VB2003 because gid appears in the > debugger correctly (or as expected) but not in VB2005 - where it > shows up as "empty" - is it my installation or have I just made an > abvious goof. window? Locals window? The VB 2005 IDE shows all the instance and shared members if you extend the tooltip. GUID.Empty is one member. If you look in the locals window in VS 2003 and expand the object, it also shows the Empty member, but not in the tooltip. Armin Hi,
Yes, I think that is where I have become confused. The fact that the local and watch windows don't show the guid value, but do expand to the empty member made me think the guid was empty when in fact it isn't. If I perform the gid.tostring when the code is at a breakpoint it all seems ok. - Intutively i though the watch would display the value of the GUID object - but it doesn't. (or if i try to ?gid in the command window) thanks Charles Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:%23$Kv4ShNGHA.3408@TK2MSFTNGP14.phx.gbl... > "Charles Hunt" <Char***@HuntRAD.NET> schrieb >> Hi, >> >> hmmm.. actually that does work, but my original post demonstrates a >> problem where the gid object when inspected with a break point shows >> as "empty" - but the .tostring method does infact yield a correct >> value. >> >> This is a bit different in VB2003 because gid appears in the >> debugger correctly (or as expected) but not in VB2005 - where it >> shows up as "empty" - is it my installation or have I just made an >> abvious goof. > > You didn't write how you have it displayed in the IDE: Tooltip? Watch > window? Locals window? The VB 2005 IDE shows all the instance and shared > members if you extend the tooltip. GUID.Empty is one member. If you look > in > the locals window in VS 2003 and expand the object, it also shows the > Empty > member, but not in the tooltip. > > > Armin > Just tried this in VB.Net 2003 and VB.Net 2005
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click guidtest() End Sub Sub guidtest() Dim gstring As String Dim gid As Guid gstring = Guid.NewGuid().ToString gid = New Guid(gstring) MsgBox(gid.ToString) End Sub and it works as expected hth Michel Posseth [MCP] Show quoteHide quote "Charles Hunt" <Char***@HuntRAD.NET> wrote in message news:OBXZ7FhNGHA.2336@TK2MSFTNGP12.phx.gbl... > Hi, > > hmmm.. actually that does work, but my original post demonstrates a > problem where the gid object when inspected with a break point shows as > "empty" - but the .tostring method does infact yield a correct value. > > This is a bit different in VB2003 because gid appears in the debugger > correctly (or as expected) but not in VB2005 - where it shows up as > "empty" - is it my installation or have I just made an abvious goof. > > best > > Charles > > "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message > news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl... >> Hi, >> >> I added this line after you created gid. >> >> MessageBox.Show(gstring, gid.ToString) >> >> I get the same value in the caption and text. >> >> >> >> Ken >> ------- >> "Charles Hunt" <Char***@HuntRAD.NET> wrote in message >> news:OO7hmXgNGHA.2644@TK2MSFTNGP10.phx.gbl... >>> Hi, >>> >>> When running this code in VB2003 >>> >>> Sub guidtest() >>> >>> Dim gstring As String >>> >>> Dim gid As Guid >>> >>> gstring = Guid.NewGuid().ToString >>> >>> gid = New Guid(gstring) >>> >>> End Sub >>> >>> variable GID gets the correct value derived from gstring - however when >>> i do >>> this in VB2005 it doesn't work - i just get an empty GUID - this seems >>> like >>> a fairly serious problem so i am assuming i have made some incorrect >>> basic >>> assumptions. >>> >>> my installation of VS2005 went pretty smoothly from memory and it pretty >>> much has default options. >>> >>> Can anyone replicate this problem / error? >>> >>> is it a bug in VS/VB or .NET? >>> >>> I look forward to hearing from anyone with any ideas here as I have >>> spent >>> about 10 hours trying to see what I have done wrong. >>> >>> best >>> >>> Charles >>> >>> >>> >> >> > > Hi,
The problem I had was that in the watch window is doesn't show any value - which made me think it was unassigned or empty. this is still puzzling me but I will try accept it as "the way it is" best Charles Show quoteHide quote "m.posseth" <mich***@nohausystems.nl> wrote in message news:%23cJQnVhNGHA.3788@TK2MSFTNGP09.phx.gbl... > > Just tried this in VB.Net 2003 and VB.Net 2005 > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click > > guidtest() > > End Sub > > Sub guidtest() > > Dim gstring As String > > Dim gid As Guid > > gstring = Guid.NewGuid().ToString > > gid = New Guid(gstring) > > MsgBox(gid.ToString) > > End Sub > > > and it works as expected > > hth > > Michel Posseth [MCP] > > > > > > > "Charles Hunt" <Char***@HuntRAD.NET> wrote in message > news:OBXZ7FhNGHA.2336@TK2MSFTNGP12.phx.gbl... >> Hi, >> >> hmmm.. actually that does work, but my original post demonstrates a >> problem where the gid object when inspected with a break point shows as >> "empty" - but the .tostring method does infact yield a correct value. >> >> This is a bit different in VB2003 because gid appears in the debugger >> correctly (or as expected) but not in VB2005 - where it shows up as >> "empty" - is it my installation or have I just made an abvious goof. >> >> best >> >> Charles >> >> "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message >> news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl... >>> Hi, >>> >>> I added this line after you created gid. >>> >>> MessageBox.Show(gstring, gid.ToString) >>> >>> I get the same value in the caption and text. >>> >>> >>> >>> Ken >>> ------- >>> "Charles Hunt" <Char***@HuntRAD.NET> wrote in message >>> news:OO7hmXgNGHA.2644@TK2MSFTNGP10.phx.gbl... >>>> Hi, >>>> >>>> When running this code in VB2003 >>>> >>>> Sub guidtest() >>>> >>>> Dim gstring As String >>>> >>>> Dim gid As Guid >>>> >>>> gstring = Guid.NewGuid().ToString >>>> >>>> gid = New Guid(gstring) >>>> >>>> End Sub >>>> >>>> variable GID gets the correct value derived from gstring - however when >>>> i do >>>> this in VB2005 it doesn't work - i just get an empty GUID - this seems >>>> like >>>> a fairly serious problem so i am assuming i have made some incorrect >>>> basic >>>> assumptions. >>>> >>>> my installation of VS2005 went pretty smoothly from memory and it >>>> pretty >>>> much has default options. >>>> >>>> Can anyone replicate this problem / error? >>>> >>>> is it a bug in VS/VB or .NET? >>>> >>>> I look forward to hearing from anyone with any ideas here as I have >>>> spent >>>> about 10 hours trying to see what I have done wrong. >>>> >>>> best >>>> >>>> Charles >>>> >>>> >>>> >>> >>> >> >> > > >
Help creating custom ComboBox control
Can opacity/transparency be adjusted within components? No tables visible in SQL Server connection Text Files Changing CheckedState or Checked-value without raising ItemChecked-event Opacity Unable to open file Control Arrays Progress bar - No activity Basic How To Question: Class Library or Windows Control Library |
|||||||||||||||||||||||