-
- VBForums
- Visual Bones
- Visual Bones .NET
- VS 2019 [RESOLVED] Visual Bones ... trouble with writing to a file
-
May 12th, 2019,02:24 PM #1 Thread Starter Member [RESOLVED] Visual Basic ... trouble with writing to a file I'1000 trying to write variable values to a file from a Console App. The code I'g using is below. There is also a namespace saved as a separate file that'due south also shown. Can anyone tell me what's wrong with this? Code: 'plot r and z Dim file As Organisation.IO.StreamWriter Dim TestStr As String file = My.Calculator.FileSystem.OpenTextFileWriter("C:\Users\denny\source\repos\atomizer\test.txt", True) For jz = 0 To nz For ir = 0 To nr 'TestStr = Format(ir, jz, r(ir, jz), "Scientific", z(jz), "Scientific") 'file.WriteLine("TestStr") file.WriteLine("writing") Next ir Next jz file.Shut() Lawmaking: Namespace My Friend Grade Computer Public Shared Belongings FileSystem As Object End Course Cease Namespace This is the line that generates an exception: file = My.Computer.FileSystem.OpenTextFileWriter("C:\Users\denny\source\repos\atomizer\examination.txt", Truthful) -
May 12th, 2019,05:35 PM #2 Re: Visual Basic ... trouble with writing to a file Originally Posted by DennyGinson This is the line that generates an exception: file = My.Reckoner.FileSystem.OpenTextFileWriter("C:\Users\denny\source\repos\atomizer\test.txt", Truthful) What exception? That is diagnostic information that you don't keep from the people yous want to diagnose the issue for yous. ALWAYS provide a Full and Clear caption of the trouble. What actually happens is part of that. Also, did you lot write that second code snippet yourself? If so, get rid of it. -
May 12th, 2019,05:39 PM #3 Re: Visual Bones ... problem with writing to a file Also, information technology is proficient exercise to utilise a Using block to create and implicitly close/dispose objects that implement the IDisposable interface, which the StreamWriter class does: vb.net Code: -
Using writer = My.Computer.FileSystem.OpenTextFileWriter("file path here", True) -
'Write to file here. -
Cease Using -
May twelfth, 2019,06:41 PM #4 Thread Starter Member Re: Visual Bones ... problem with writing to a file Here's the exception referencing the afor mentioned line of lawmaking. Exception thrown: 'Organization.NullReferenceException' in Microsoft.VisualBasic.dll An unhandled exception of type 'System.NullReferenceException' occurred in Microsoft.VisualBasic.dll Object variable or With block variable not set. -
May 12th, 2019,06:51 PM #5 Thread Starter Member Re: Visual Basic ... trouble with writing to a file Do I still demand a namespace named My with a Class named Reckoner? I'm non new to programming only I am relatively new to OOP (as an explanation for what might be a dumb question) -
May twelfth, 2019,07:23 PM #half-dozen Re: Visual Basic ... trouble with writing to a file At that place is already already a "My" namespace, but VB.NET Code: -
Using writer = My.Estimator.FileSystem.OpenTextFileWriter("C:\AJunk2015\exam.txt", Truthful) -
writer.WriteLine("Here is the showtime string.") -
End Using -
May 13th, 2019,06:15 AM #seven Re: Visual Bones ... problem with writing to a file Originally Posted by DennyGinson Exercise I still need a namespace named My with a Class named Computer? I'm non new to programming but I am relatively new to OOP (as an explanation for what might be a dumb question) In the IDE, Intellisense should be trying to help yous out by showing you a list of things it already knows about as yous type. When you typed "chiliad", you should have gotten a list of things starting with "M". When you lot typed "y", so "My{}" should have been i of the things on the list. If y'all blazon "." (you've now blazon "my."), the editor should have changed information technology to "My." and showed you a list of items that could possibly follow "My.", which "Calculator" should accept been on that list. You lot should have been able to blazon the "c" and "Reckoner" would accept been selected, and so if you hit the Tab cardinal, the editor would take filled that in for you lot. I don't necessarily type all that quickly, simply some other programmer who was watching me enter some VB code in Visual Studio made a comment about not having seen someone type in code so quickly. It wasn't that I was so quick, just that I'm very utilise to watching the list and after typing a few letters (oftentimes one or two), the items desired is selected in the list, and then I hit tab and a flow to become to the side by side level of the hierarchy (if needed). In the particular case he was observing, I was checking for a button in a mouse event, so that tin wait impressive to the uninitiated because of the length of the text the editor can fill in for you equally you blazon. In particular I typed in "If due east.b{tab} = l{tab}" Which the editor modified to "If e.Button = Windows.Forms.MouseButtons.Left" I've probably typed that so many times that I don't accept to hesitate when watching the listing, so my quick typing of 10 characters results in 43 characters on the screen, so I can see how that looks like yous're typing exceeding fast. Of grade later I blazon "then" at the end of the line and hitting return, the editor changes information technology to "Then" and automatically inserts an "End If" below the new blank line so you don't accept to type that in later. -
May 13th, 2019,xi:03 AM #viii Thread Starter Member Re: Visual Basic ... trouble with writing to a file Computer does not come up up later on My. and the compiler issues an error (BC30456) "Computer is not a member of atomizer.My" and (BC30451) "Format is not alleged …" -
May 13th, 2019,xi:25 AM #ix Re: Visual Basic ... problem with writing to a file Originally Posted past DennyGinson Computer does not come up after My. and the compiler issues an error (BC30456) "Estimator is not a member of atomizer.My" and (BC30451) "Format is not declared …" That'due south because you put this into your projection that you shouldn't accept: vb Code: -
Namespace My -
Friend Grade Computer -
Public Shared Property FileSystem As Object -
End Class -
Terminate Namespace If you delete all of that code the rest of your code will piece of work correctly again. -
May 13th, 2019,xi:49 AM #x Thread Starter Fellow member Re: Visual Basic ... problem with writing to a file I deleted the file … still get the aforementioned errors. Here's the lawmaking every bit it is now: Code: 'plot r and z Dim TestStr As String Using writer = My.Calculator.FileSystem.OpenTextFileWriter("C:\Users\denny\source\repos\atomizer\test.txt", True) Format(jz, "0") Format(ir, "0") Format(r, 0000E+00) Format(z, 0000E+00) For jz = 0 To nz For ir = 0 To nr TestStr = (jz, ir, r(ir, jz), z(jz)) writer.WriteLine("TestStr") Next ir Next jz End Using half-dozen errors are returned: Severity Code Clarification Projection File Line Suppression State Error BC30311 Value of type '(jz Every bit Long, ir As Long, Double, Double)' cannot be converted to 'String'. atomizer C:\Users\denny\source\repos\atomizer\Plan.vb 2672 Active Error BC30456 'Computer' is not a fellow member of 'atomizer.My'. atomizer C:\Users\denny\source\repos\atomizer\Plan.vb 2665 Active Error BC30451 'Format' is non declared. It may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Program.vb 2666 Active Error BC30451 'Format' is non alleged. It may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Program.vb 2667 Active Error BC30451 'Format' is not declared. It may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Programme.vb 2668 Agile Fault BC30451 'Format' is non declared. It may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Plan.vb 2669 Active Terminal edited by DennyGinson; May 13th, 2019 at 11:56 AM. -
May 13th, 2019,12:08 PM #xi Thread Starter Member Re: Visual Basic ... problem with writing to a file Caught a couple errors … corrected them: Code: 'plot r and z Using author = My.Computer.FileSystem.OpenTextFileWriter("C:\Users\denny\source\repos\atomizer\examination.txt", True) Format(jz, "0") Format(ir, "0") Format(r, "0000E+00") Format(z, "0000E+00") For jz = 0 To nz For ir = 0 To nr author.WriteLine(jz, ir, r(ir, jz), z(jz)) Adjacent ir Next jz Finish Using Error codes: Severity Lawmaking Description Projection File Line Suppression State Error BC30456 'Reckoner' is not a fellow member of 'atomizer.My'. atomizer C:\Users\denny\source\repos\atomizer\Plan.vb 2664 Active Error BC30451 'Format' is not declared. It may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Programme.vb 2665 Agile Fault BC30451 'Format' is non declared. Information technology may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Program.vb 2666 Agile Fault BC30451 'Format' is not declared. It may exist inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Program.vb 2667 Active Error BC30451 'Format' is non alleged. It may be inaccessible due to its protection level. atomizer C:\Users\denny\source\repos\atomizer\Program.vb 2668 Active -
May 13th, 2019,12:19 PM #12 Re: Visual Basic ... trouble with writing to a file I would test using a new project. Select to create a project, and choose which type you want. I would recommend a Windows Course projection, but you can try a Console application again. If y'all Console Application, you should exist presented with a Main Sub, and I would try typing in "My." in that sub and see what happens. I don't take VS2019 installed anywhere, but I assume it hasn't changed that much, but since in that location were dissimilar variations of the install depending on your target earlier, i.e. Windows Desktop or Net Core, etc. perchance it is possible you're non using the variation you should be using for Windows Desktop application development. -
May 13th, 2019,01:46 PM #thirteen Re: Visual Basic ... trouble with writing to a file What happens if you get rid of My.Computer? Y'all don't demand to add together all the decorations, and information technology may well be that just getting rid of the My.Calculator. will allow the compiler to notice the right type. On the other hand, I don't use VS2019, all the same, and things do change. My usual ho-hum signature: Nothing -
May 13th, 2019,03:09 PM #14 Thread Starter Member Re: Visual Bones ... trouble with writing to a file The projection was started the way passel mentioned … as for getting rid of My.Computer, equally adding Code: Individual ReadOnly FileSystem As Object (which cleared the "not declared" fault) I've got this (but Format is withal "not declared"): Code: 'plot r and z Using writer = FileSystem.OpenTextFileWriter("C:\Users\denny\source\repos\atomizer\test.txt", True) Format(jz, "0") Format(ir, "0") Format(r, "0000E+00") Format(z, "0000E+00") For jz = 0 To nz For ir = 0 To nr writer.WriteLine(jz, ir, r(ir, jz), z(jz)) Next ir Adjacent jz End Using -
May 13th, 2019,03:nineteen PM #fifteen Thread Starter Member Re: Visual Basic ... trouble with writing to a file I as well got an error … Severity Lawmaking Description Project File Line Suppression State Mistake BC35000 Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.Conversions.ChangeType' is not defined. atomizer C:\Users\denny\source\repos\atomizer\Program.vb 2679 It's for the line writer.writeLine(... I'm lost! Last edited by DennyGinson; May 13th, 2019 at 03:23 PM. -
May 13th, 2019,05:27 PM #16 Re: Visual Basic ... trouble with writing to a file I still recall you lot should try a new project. Your current project may be jacked up, so that continuing to patch it isn't getting rid of crud that has built upwards inside it. Trying to fix something that should exist like shooting fish in a barrel, just has been damaged in some unknown way, can oftentimes atomic number 82 to frustration. Starting with a clean slate, and fugitive the mistakes that may take got you into the wood, is advisable. Starting with a elementary concept and making sure that works before adding the next "uncomplicated" bit of code instead of adding all the code in a big bang approach, tin can also help save time. It is easier to test one thing, than to troubleshoot twenty problems. An example of a uncomplicated test of writing strings to a file for instance, although I don't have 2019, and I haven't started using 2017 for much nevertheless since it isn't what we currently use at work, I do take 2017 installed on this computer, and after getting the Microsoft account straightened out, and the license validated, I can do a examination using the VS2017 installed on this computer. Then, I selected Create New project. Then picked "Visual Basic", and then "Windows Desktop" and finally "Console App". The IDE presented me a Module1.vb file with the following contents. Code: Module Module1 Sub Chief() End Sub Finish Module I added five lines to the Module Code: Module Module1 Sub Main() Using writer = My.Calculator.FileSystem.OpenTextFileWriter("C:\c\test.txt", Fake) For i As Integer = ane To 10 writer.WriteLine(String.Format("Line {0}", i)) Next End Using Stop Sub Cease Module I clicked the "Start" selection on the toolbar. After a quick compile, the console window open up briefly, the code was run and the console window closed. I checked the "C:\c" directory and doubleClicked on the Text.txt file, and the file opened in Notepad with the following contents. Lawmaking: Line ane Line two Line 3 Line four Line 5 Line half-dozen Line 7 Line eight Line 9 Line 10 The program ran as I would expect, and produced the file with the contents I expected. This is a quick and unproblematic examination. If y'all showtime a new project, and do this same test, and it doesn't work, then that is an indication that there is a critical problem with the way you have things set up. Last edited by passel; May 13th, 2019 at 05:44 PM. -
May 13th, 2019,05:39 PM #17 Re: Visual Basic ... trouble with writing to a file I thoroughly second that proposition, especially after reading the first snippet in #14. That makes me queasy, every bit information technology sounds more like tossing lawmaking at a problem until the errors go away, rather than understanding the solution. I'm not quite sure what Code: Private ReadOnly FileSystem As Object even is. If the ReadOnly wasn't in that location, then this would be declaring a new variable of type Object with the name FileSystem. Yes, that would mean that FileSystem was declared...it isn't the FileSystem yous are trying to use subsequently, considering that object is subconscious by the new i you declared. Notwithstanding, I've never seen ReadOnly used in an object proclamation. Therefore, that looks a whole lot similar a property declaration, except that it appears to exist missing the word Property for it to be a belongings. Then, what is that, and why do y'all recollect it fixes something? Nevermind the kickoff office. I didn't know you could put ReadOnly into a variable declaration. In all these years, I've never done that, and don't see much utilise for it. However, in this case it is pretty bad. All that line does is delays finding a problem until runtime, at that point, the FileSystem object volition not accept the desired method and the program will crash. Last edited by Shaggy Hiker; May 13th, 2019 at 05:47 PM. My usual slow signature: Nothing -
May 13th, 2019,06:45 PM #18 Re: Visual Basic ... trouble with writing to a file You shouldn't exist using Format anyway. If y'all're using VB.Net so use VB.Net, not VB6. You tin can call Cord.Format for composite formatting or just call ToString on the value if formatting a single value. The lawmaking you have is pointless anyhow considering Format returns a value and you're not using any of the results anyhow, so what'southward the point? -
May 13th, 2019,07:07 PM #19 Re: Visual Bones ... problem with writing to a file There probably isn't a point at this point. You accept someone quite familiar with FORTRAN and not familiar with Visual Basic of whatever version at this point. The way FORTRAN uses Format statements to control the format of data written to files compared to the way Visual Bones does file I/O is a world of departure. I think we just have a case of trying to bound too quickly into taking FORTRAN code and trying to port it to .Net without learning the basics of VB.Net first. In this instance, a FORTRAN person may know you have to create format strings to pass equally a parameter to the Write statement to controls how the variables are encoded and cease up searching for Format in .Net and retrieve there is something analogous in their utilize. There are bound to be some missteps along the fashion. I think this is a case of being a bit too enthusiastic and jumping from the diving board when some pond lessons in the shallow stop first are in order. -
May 13th, 2019,08:33 PM #20 Thread Starter Member Re: Visual Bones ... trouble with writing to a file Interesting … the "Private ReadOnly FileSystem Equally Object" is what Visual Studio 2019 (Intellisense) offered as a set … as was the Namespace and Form that was deleted earlier. Yes, I am a 40 year veteran of Fortran who was ordered to do a VBA/Excel projection that blew Excel upward (froze it like a rock). The code was developed in VBA and copied to Visual Studio. It works fine (in the Excel environment) and all I'chiliad trying to do is catechumen the parts of the code that wrote to cells in a spreadsheet to write to an external file. Doesn't sound hard does information technology? Well … it is. And then … you lot're right … I pigeon in … but the diving board was a plank I was forced to walk. You tin can't spend time studying when you're busy treading h2o. passel … thanks … I'll try a new project … all I'm doing is chasing my tail at this point. -
May 13th, 2019,09:54 PM #21 Re: Visual Basic ... trouble with writing to a file The My namespace and a lot of functionality in it is provided for free in many VB projects. If yous write code that tries to use a type that doesn't exist then VS will try to be helpful and offering generic solutions to the problem but creating your own My namespace is never a solution. The question that needs to be answered is why you don't accept a My namespace to begin with. Possibly it'south a bug in VS 2019, which is still fairly new. Possibly it has something to do with the type of project you lot created in the offset place or something that you did to it subsequently creating it. I just created a VB Panel app project targeting .Internet 4.seven.2 in VS 2017 and My.Computer.FileSystem was available to me. I don't accept VS 2019 installed yet to examination information technology. Take yous tried creating a new Console app projection and checking whether it's available to you in that location? That said, you really don't accept to utilise My.Computer.FileSystem in most cases anyway. You can achieve the aforementioned effect every bit from calling OpenTextFileWriter by invoking a constructor of the StreamWriter class. Both will result in the creation and return of a StreamWriter object, then I'd just get ahead and do that. Personally, I'd be doing that all the fourth dimension anyway. I only use the My namespace when it adds 18-carat value over the culling. As someone who codes in C#, where there is no My namespace, every bit well as VB, I prefer to write as close to the same lawmaking in both languages as I tin. -
May 13th, 2019,10:45 PM #22 Thread Starter Member Re: Visual Basic ... trouble with writing to a file jmcilhinney … thanks! Would you lot requite me an example of "invoking a constructor of the StreamWriter class"? -
May 13th, 2019,11:49 PM #23 Re: Visual Basic ... trouble with writing to a file You invoke a constructor using the New keyword, which I expect that yous have done before. If not, you should do some reading on the subject. If you want to know what constructors are available on that type, Intellisense tin tell you or you tin read the documentation, which you tin can navigate to direct or observe with a search using the obvious keywords, i.e. "streamwriter constructor". -
May 14th, 2019,09:10 AM #24 Re: Visual Basic ... trouble with writing to a file Originally Posted by DennyGinson Interesting … the "Individual ReadOnly FileSystem As Object" is what Visual Studio 2019 (Intellisense) offered as a set … as was the Namespace and Class that was deleted earlier. Yes, VS tries to exist helpful. That doesn't hateful it'southward right. When the suggestion is basically, "I don't recognize this affair, would you like me to create it?" The respond is NO!!! If the help is a suggestion to import this or that, then become for it. When it wants to create something that you lot think should be, then you are misunderstanding something, and that help is non helpful. The reason that is there is so that people can write forth the lines of "at that place will be this part, I but oasis't written it, all the same", at which point VS is offering to create a stub for you to mankind out later. If that's the way y'all work, then go for information technology. However, when information technology is offering to flesh out something that you think is part of the language, or part of a library, and is NOT something that yous fully expect and intend to write yourself, then you should not accept that "help". My usual slow signature: Goose egg -
May 14th, 2019,09:34 AM #25 Thread Starter Fellow member Re: Visual Basic ... trouble with writing to a file Cheers folks! I appreciate the help! -
May 14th, 2019,10:54 AM #26 Thread Starter Fellow member Re: Visual Basic ... trouble with writing to a file Update … I started a new projection in VS 2019 and tried the lawmaking snippet to write to a file … and got the same fault. Manifestly either there'southward a problems in VS 2019 or something regarding this topic has changed. I'thousand downloading VS 2017 and trying this again. -
May 14th, 2019,11:38 AM #27 Re: Visual Bones ... trouble with writing to a file I but happened to install VS2019 customs a few minutes ago on this machine. Seems like a reasonable kickoff test. The menu is a piffling flake different. Start, selected "Create New Projection". And so select "Panel App", and sub particular "Windows" (had "C++" , "Windows", and "Panel" as my choices in this installation). I'm non sure what the divergence is betwixt the sub items "Windows" and "Console". I guess if you're running some kind of non-gui command line server interface, yous would choose Console? hmmm, that didn't seem to do anything. In that location are a lot of options, so scrolling farther down the selections and nosotros have "Console App (.Net Framework). Clicking on that doesn't seem to exercise anything either. Lets see what else we accept... Ok filter selections at the top. And so, for Project type, let's select "Desktop". For Platform, permit's select "Windows". For Language, allow'southward select "Visual Basic" hmm, I don't see Console app as an pick, just WPF (.Cyberspace), Win Forms (.Cyberspace), WPF Browser (.Internet), Win Service (.Net), Empty projection (.Internet) and Shared Projection. Get back to Projection Type filter selection, and select Console App. At present only have one selection showing, Console App (with sub items "Visual Basic" "Windows" "Console"). The sub items must just be the specifics of the type of project, non selections themselves. I think I see my upshot, I'k suppose to click on the project type then select "Adjacent" button at the bottom (or double click project). On the adjacent page, select Create push button. Now I get the familiar starting code snippet Code: Module Module1 Sub Main() End Sub End Module And add the four lines a Lawmaking: Module Module1 Sub Principal() Using writer = My.Computer.FileSystem.OpenTextFileWriter("C:\c\test.txt", False) For i As Integer = 1 To 10 writer.WriteLine(String.Format("Line {0}", i)) Next End Using Terminate Sub Cease Module Click the get-go push, and it runs and produces the file as before. So, VS2019 works as expected, although in that location are a lot of options and perhaps somehow you lot chose a console App without .Net support, which is why you're having issues, although I wouldn't think that would be possible with a VB.Net project. Of grade, possibly you lot don't have a VB.Cyberspace project, and are typing VB.Net lawmaking into a panel project that is neither vb.cyberspace or .Net in general. -
May 14th, 2019,11:52 AM #28 Thread Starter Member Re: Visual Basic ... trouble with writing to a file Ok … the 2017 version works with the method described above. I'one thousand sticking with that. -
May 14th, 2019,12:38 PM #29 Thread Starter Fellow member Re: Visual Basic ... trouble with writing to a file Well-nigh there! The code below works ... Lawmaking: Module Module1 Sub Master() Dim r As Double Dim z As Double Using writer = My.Computer.FileSystem.OpenTextFileWriter("C:\users\denny\source\repos\atomizer model\exam.txt", False) r = i.0 z = two.0 For j = 1 To three For i As Integer = 1 To 4 author.WriteLine(String.Format("{0}", j, "{0}", i, "{0.0000E0}", r, "{0.0000E0}", z)) Next Next End Using End Sub Finish Module What I desire is this: 1 i 1.0000e01 two.0000E01 1 ii 1.0000e01 ii.0000E01 ane 3 1.0000e01 ii.0000E01 ane 4 1.0000e01 2.0000E01 2 i 1.0000e01 two.0000E01 two ii 1.0000e01 2.0000E01 2 iii 1.0000e01 2.0000E01 2 4 1.0000e01 2.0000E01 3 1 i.0000e01 two.0000E01 iii ii 1.0000e01 2.0000E01 iii 3 1.0000e01 two.0000E01 3 4 ane.0000e01 2.0000E01 What I get is this: 1 i 1 one two 2 ii two three 3 three 3 If I employ Write(" .... I get this: 111122223333 The variables r and z are not writing and the format is not what I want … how do I do this correctly? -
May 14th, 2019,01:21 PM #30 Re: Visual Basic ... trouble with writing to a file In Visual Studio, if you put your cursor on the discussion "Format" in that line, and press the F1 key, you should go aid with how to use the method. I would look at the numeric formats, there should be ane for engineering notation. -
May 14th, 2019,01:23 PM #31 Thread Starter Member Re: Visual Bones ... trouble with writing to a file Here'south the lawmaking now: Lawmaking: Module Module1 Sub Principal() Dim r As Double Dim z As Double Using writer = My.Computer.FileSystem.OpenTextFileWriter("C:\users\denny\source\repos\atomizer model\test.txt", Imitation) r = i.0 z = two.0 For j = ane To iii For i As Integer = ane To 4 writer.Write(String.Format("{0}", j)) writer.Write(String.Format(" {0}", i)) writer.Write(String.Format(" ")) writer.Write(Cord.Format("0.0###Due east+00", r)) author.Write(String.Format(" ")) writer.Write(String.Format("0.0###Eastward+00", z)) writer.WriteLine() Next Next End Using Terminate Sub End Module Here's the output: 1 1 0.0###E+00 0.0###E+00 one 2 0.0###Eastward+00 0.0###Due east+00 1 3 0.0###E+00 0.0###Eastward+00 1 4 0.0###E+00 0.0###Due east+00 2 ane 0.0###E+00 0.0###Due east+00 ii 2 0.0###E+00 0.0 ###E+00 2 iii 0.0###E+00 0.0###E+00 2 4 0.0###Due east+00 0.0###Eastward+00 3 1 0.0###E+00 0.0###E+00 3 2 0.0###E+00 0.0###E+00 three 3 0.0###East+00 0.0###Due east+00 3 4 0.0###Due east+00 0.0###Due east+00 Equally yous can see, I've got the organisation the way I desire it … at present how exercise I get the variable values to be written … information technology's just writing the cord that specifies the format of the variable value. There is a space between each value written that'southward not showing up here. Last edited by DennyGinson; May 14th, 2019 at 01:34 PM. -
May 14th, 2019,01:37 PM #32 Re: Visual Bones ... trouble with writing to a file There are multiple ways you tin format. After reading a bit from the pages found by hitting the Help key (F1), I tried this line: writer.WriteLine(Cord.Format("{0} {1} {ii} {three}", j, i, r.ToString("e4"), z.ToString("e4"))) It produced Lawmaking: 1 one 1.0000e+000 2.0000e+000 one two 1.0000e+000 2.0000e+000 i iii one.0000e+000 2.0000e+000 1 4 i.0000e+000 2.0000e+000 2 1 ane.0000e+000 2.0000e+000 two 2 1.0000e+000 2.0000e+000 2 iii 1.0000e+000 2.0000e+000 ii 4 1.0000e+000 ii.0000e+000 3 1 1.0000e+000 two.0000e+000 3 two 1.0000e+000 2.0000e+000 3 3 1.0000e+000 2.0000e+000 three iv i.0000e+000 ii.0000e+000 Not quite the format y'all wanted. You may accept to look at the link of custom numeric formats on that folio, to see if you can coerce to the format you desire. (p.south. only based on the previous post you posted while I tried this, perhaps this format is acceptable). Last edited past passel; May 14th, 2019 at 01:44 PM. -
May 14th, 2019,01:42 PM #33 Re: Visual Basic ... trouble with writing to a file I changed r to be 12 and z to exist 23, to run into if it produced a non-zero exponent, and this was the result. Code: 1 1 1.2000e+001 2.3000e+001 1 two 1.2000e+001 ii.3000e+001 ane 3 1.2000e+001 ii.3000e+001 ane 4 one.2000e+001 2.3000e+001 2 1 1.2000e+001 two.3000e+001 2 2 one.2000e+001 2.3000e+001 2 3 one.2000e+001 2.3000e+001 2 four 1.2000e+001 2.3000e+001 3 one 1.2000e+001 2.3000e+001 three 2 1.2000e+001 2.3000e+001 3 three 1.2000e+001 2.3000e+001 3 4 ane.2000e+001 2.3000e+001 -
May 14th, 2019,01:55 PM #34 Re: Visual Bones ... trouble with writing to a file Every bit explained on the folio that F1 takes you to, you could add spacing to your string if y'all wanted fixed number of spaces betwixt fields, or you could specify a "field" size, so the field will be padded with a variable number of space depending on the number of characters in the value, to help go along things aligned in columns. In the 3rd case below, you see I added the e4 format to the field tag, rather than in the .ToString method of the variable. Code: Module Module1 Individual r As Double, z As Double Sub Chief() Using writer = My.Computer.FileSystem.OpenTextFileWriter("C:\c\test.txt", False) r = 12.0 z = 23.0 For j = 1 To 3 For i As Integer = one To iv writer.WriteLine(String.Format("{0} {1} {2} {3}", j, i, r.ToString("e4"), z.ToString("e4"))) Next Adjacent writer.WriteLine() For j = 1 To 3 For i As Integer = 1 To 4 writer.WriteLine(String.Format("{0} {ane,6} {2} {3,15}", j, i, r.ToString("e4"), z.ToString("e4"))) Next Next writer.WriteLine() For j = 1 To three For i As Integer = 1 To 4 author.WriteLine(String.Format("{0} {1,6} {ii:e4} {3,xv:e4}", j, i, r, z)) Adjacent Side by side End Using End Sub End Module All iii loops create the same output, with this set of numbers. Of course the first ane with stock-still number of spaces between fields will differ from the 2nd 2 if the number of characters in a given field increment (i.e. more pregnant digits in the number). Code: 1 1 i.2000e+001 ii.3000e+001 1 2 1.2000e+001 two.3000e+001 ane 3 ane.2000e+001 two.3000e+001 one 4 1.2000e+001 2.3000e+001 two 1 one.2000e+001 two.3000e+001 2 2 1.2000e+001 ii.3000e+001 ii 3 ane.2000e+001 2.3000e+001 2 4 1.2000e+001 two.3000e+001 3 one 1.2000e+001 2.3000e+001 3 2 1.2000e+001 ii.3000e+001 iii 3 1.2000e+001 2.3000e+001 3 4 i.2000e+001 ii.3000e+001 one i one.2000e+001 2.3000e+001 1 2 1.2000e+001 2.3000e+001 one iii i.2000e+001 2.3000e+001 1 iv one.2000e+001 two.3000e+001 2 one 1.2000e+001 2.3000e+001 2 2 1.2000e+001 2.3000e+001 two 3 1.2000e+001 2.3000e+001 2 4 1.2000e+001 2.3000e+001 3 1 1.2000e+001 two.3000e+001 3 2 ane.2000e+001 two.3000e+001 3 iii 1.2000e+001 2.3000e+001 3 iv ane.2000e+001 2.3000e+001 1 ane 1.2000e+001 ii.3000e+001 1 2 1.2000e+001 2.3000e+001 ane iii 1.2000e+001 two.3000e+001 one 4 one.2000e+001 two.3000e+001 2 ane 1.2000e+001 2.3000e+001 2 2 ane.2000e+001 2.3000e+001 2 3 1.2000e+001 ii.3000e+001 two four one.2000e+001 2.3000e+001 iii 1 ane.2000e+001 2.3000e+001 3 2 1.2000e+001 2.3000e+001 3 3 i.2000e+001 two.3000e+001 3 four 1.2000e+001 2.3000e+001 Last edited by passel; May 14th, 2019 at 02:06 PM. -
May 14th, 2019,01:58 PM #35 Thread Starter Member Re: Visual Bones ... problem with writing to a file Outstanding! It works … would you explain the ("{0} {1} {2} {3} ..." it plain works but, what, specifically, is it doing? -
May 14th, 2019,02:00 PM #36 Re: Visual Bones ... problem with writing to a file Originally Posted by DennyGinson Outstanding! It works … would y'all explain the ("{0} {1} {2} {3} ..." information technology evidently works but, what, specifically, is information technology doing? https://docs.microsoft.com/en-the states/dot...tframework-4.8 -
May 14th, 2019,02:12 PM #37 Re: Visual Basic ... trouble with writing to a file Originally Posted by DennyGinson Outstanding! It works … would you explain the ("{0} {1} {two} {3} ..." it obviously works but, what, specifically, is information technology doing? Effort changing the cord to ("{3}, {2}, {1}, {0}" or ("{0} {0}, {0}, {1}, {i}" and see the event and see if you lot can empirically effigy out what those might be. Or, y'all could read the documentation as PlausiblyDamp suggests. Part way downwardly that page, you'll run into a bunch of examples, such as this one, which should also assistance divine what those tags correlate to. Code: Dim southward As Cord = String.Format("At {0}, the temperature is {1}�C.", Appointment.At present, 20.4) ' Output similar to: 'At 4/ten/2015 ix:29:41 AM, the temperature is 20.4�C.' -
May 14th, 2019,03:04 PM #38 Thread Starter Member Re: Visual Basic ... trouble with writing to a file Thanks! I will definitely cheque that out. BUT … I'm getting an error on the call of this subroutine (call is below): Code: 'Summate and store grid prison cell face areas, skew terms, and normal face unit of measurement vectors GridProp(n, nr, nz, r, z, n1r_west, n1r_east, n1r_south, n1r_north, n1z_west, n1z_east, n1z_south, n1z_north, n2r_west, n2r_east, n2r_south, n2r_north, n2z_west, n2z_east, n2z_south, n2z_north, aface_west, aface_east, aface_south, aface_north, delta_xsi1_west, delta_xsi1_east, delta_xsi1_south, delta_xsi1_north, delta_xsi2_west, delta_xsi2_east, delta_xsi2_south, delta_xsi2_north, aface_low, aface_high, w_index, e_index, s_index, n_index, se_index, ne_index, sw_index, nw_index) Here's the error: Severity Code Description Projection File Line Suppression State Error BC30521 Overload resolution failed because no accessible 'GridProp' is most specific for these arguments: 'Public Sub GridProp(northward Every bit Integer, nr As Integer, nz As Integer, r Every bit Double(*,*), z As Double(), n1r_west Equally Double(), n1r_east Every bit Double(), n1r_south As Double(), n1r_north As Double(), n1z_west Every bit Double(), n1z_east As Double(), n1z_south Equally Double(), n1z_north As Double(), n2r_west As Double(), n2r_east As Double(), n2r_south As Double(), n2r_north Every bit Double(), n2z_west Every bit Double(), n2z_east As Double(), n2z_south As Double(), n2z_north Equally Double(), aface_west Equally Double(), aface_east Equally Double(), aface_south As Double(), aface_north Equally Double(), delta_xsi1_west Every bit Double(), delta_xsi1_east As Double(), delta_xsi1_south As Double(), delta_xsi1_north Equally Double(), delta_xsi2_west As Double(), delta_xsi2_east Equally Double(), delta_xsi2_south As Double(), delta_xsi2_north As Double(), aface_low As Double(), aface_high Every bit Double(), w_index As Integer, e_index As Integer, s_index As Integer, n_index As Integer, se_index As Integer, ne_index Every bit Integer, sw_index As Integer, nw_index As Integer)': Not most specific. 'Public Sub GridProp(due north As Integer, nr As Integer, nz Every bit Integer, r Equally Double(*,*), z As Double(), n1r_west Every bit Double(), n1r_east Every bit Double(), n1r_south As Double(), n1r_north Every bit Double(), n1z_west Every bit Double(), n1z_east Every bit Double(), n1z_south As Double(), n1z_north Equally Double(), n2r_west As Double(), n2r_east As Double(), n2r_south As Double(), n2r_north As Double(), n2z_west As Double(), n2z_east As Double(), n2z_south As Double(), n2z_north As Double(), aface_west As Double(), aface_east As Double(), aface_south As Double(), aface_north As Double(), delta_xsi1_west As Double(), delta_xsi1_east Equally Double(), delta_xsi1_south As Double(), delta_xsi1_north As Double(), delta_xsi2_west Every bit Double(), delta_xsi2_east As Double(), delta_xsi2_south Equally Double(), delta_xsi2_north As Double(), aface_low As Double(), aface_high As Double(), w_index As Integer, e_index As Integer, s_index Equally Integer, n_index Every bit Integer, se_index Every bit Integer, ne_index Every bit Integer, sw_index As Integer, nw_index As Integer)': Not most specific. atomizer model C:\Users\denny\source\repos\atomizer model\atomizer model\Module1.vb 92 Agile Here'due south the beginning of the subroutine: Code: Public Sub GridProp(n As Integer, nr As Integer, nz Every bit Integer, r As Double(,), z As Double(), n1r_west Every bit Double(), n1r_east As Double(), n1r_south Every bit Double(), n1r_north As Double(), n1z_west As Double(), n1z_east As Double(), n1z_south As Double(), n1z_north As Double(), n2r_west As Double(), n2r_east As Double(), n2r_south As Double(), n2r_north As Double(), n2z_west Every bit Double(), n2z_east As Double(), n2z_south As Double(), n2z_north As Double(), aface_west As Double(), aface_east Every bit Double(), aface_south As Double(), aface_north As Double(), delta_xsi1_west As Double(), delta_xsi1_east As Double(), delta_xsi1_south As Double(), delta_xsi1_north As Double(), delta_xsi2_west As Double(), delta_xsi2_east As Double(), delta_xsi2_south Equally Double(), delta_xsi2_north As Double(), aface_low As Double(), aface_high As Double(), w_index As Integer, e_index As Integer, s_index Every bit Integer, n_index Every bit Integer, se_index As Integer, ne_index As Integer, sw_index Every bit Integer, nw_index As Integer) This was ok in VS2019. The primary thing is I don't understand the mistake and the documentation is just not very helpful. Thoughts? -
May 14th, 2019,03:xvi PM #39 Re: Visual Basic ... trouble with writing to a file Just hopping in to this to make this one suggestion and then I'm wishing y'all good luck and won't be able to help further. You are trying to practice way as well much at once without intermediate testing. My suggestion is to pare down your subroutine parameters to mayhap the first 5, then endeavour to call that subroutine while passing 5 appropriate values and make certain your code in the subroutine is properly handling those initial values. In one case that is working, add the next 5 parameters. And so on, until they are all added. -
May 14th, 2019,03:22 PM #40 Thread Starter Member Re: Visual Basic ... problem with writing to a file -
- VBForums
- Visual Basic
- Visual Basic .NET
- VS 2019 [RESOLVED] Visual Basic ... problem with writing to a file
Posting Permissions - You may non postal service new threads
- You may not postal service replies
- You may non post attachments
- You may not edit your posts
- BB code is On
- Smilies are On
- [IMG] code is On
- [VIDEO] code is On
- HTML code is Off
Forum Rules | Click Hither to Expand Forum to Full Width |
Belum ada Komentar untuk "Either Vcproject or Vccodemodel Is Not Ready Yet Please Close Designer and Try Again"
Posting Komentar