Sunday, July 4, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Trying to draw fibonacci spiral using condition

Posted: 04 Jul 2021 09:05 AM PDT

Generating a Fibonacci sequence with N=1,000 (X1,X2,…,Xn, where X1=1,X2=1, Xn=Xn-1+Xn-2). Using the first 9 Fibonacci numbers to plot Fibonacci spiral as showed in the following figure.

Does setting Application.ScreenUpdating=False applies to every workbook that has subsequently been opened within a subroutine?

Posted: 04 Jul 2021 09:04 AM PDT

OS: Windows 10 Pro Version 20H2 (OS Build 19042.1052)
Application: Microsoft 365 Excel Version 2106 (Build 14131.20278)
VBA: Microsoft Visual Basic for Applications 7.1 Version 1110


The module that contains the code resides in a Macro-enabled workbook, which opens other workbooks in a folder and modify each if it passes certain criteria. The workbook itself that contains the code is not being altered, it just holds the code.

I'm wondering if I need to turn Application.ScreenUpdating off and on for every subsequent workbook that will be opened within a subroutine, such as in this one:

Option Explicit    Sub Test_Code()    'Variable declaration  Dim fsoLib As Scripting.FileSystemObject  Dim strSrcPath As String  Dim fsoFolder As Scripting.Folder  Dim fsoFile As Scripting.File  Dim fsoFiles As Scripting.Files  Dim wb As Excel.Workbook  Dim wbs As Excel.Workbooks    'Assign values to variables  Set fsoLib = New Scripting.FileSystemObject  strSrcPath = "/SourcePath"  Set fsoFolder = fsoLib.GetFolder(strSrcPath)  Set fsoFiles = fsoFolder.Files  Set wbs = Excel.Workbooks    'Modify workbooks  For Each fsoFile In fsoFiles      Set wb = wbs.Open(fsoFile)        Application.ScreenUpdating = False 'TURNS OFF SCREEN UPDATING          'Code to modify workbooks here..      Application.ScreenUpdating = True 'TURNS SCREEN UPDATING BACK ON        wb.Close(True)  Next    'Housekeeping  Set fsoLib = Nothing  strSrcPath = vbEmpty  Set fsoFolder = Nothing  Set fsoFile = Nothing  Set fsoFiles = Nothing  Set wb = Nothing  Set wbs = Nothing    'Success indicator  Debug.Print "You have reached the end of the line.."    End Sub  

..or do I just place it on top and bottom, respectively? Like in this one:

Option Explicit    Sub Test_Code()  Application.ScreenUpdating = False        'Rest of the code here..    Application.ScreenUpdating = True  End Sub  

I couldn't find any resources about it on the internet that's current. I found one old discussion here but the OP had mixed results depending on whether it is run from the VBA IDE or otherwise.

I'd appreciate any help from you guys. Thank you all very much.

i can't fixe the number after the comma in c#

Posted: 04 Jul 2021 09:04 AM PDT

It's my first time with c #. I got a problem and don't how to solve I hope you help me out. Thank you in advance

this is my code:

using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using System.Threading.Tasks;    namespace ProgrammingAssignment1  {      // IMPORTANT: Only add code in the section      // indicated below. The code I've provided      // makes your solution work with the       // automated grader on Coursera        /// <summary>      /// Programming Assignment 1      /// </summary>      class Program      {          // x and y coordinates for points          static float point1X;          static float point1Y;          static float point2X;          static float point2Y;            /// <summary>          /// Calculates angle and distance between two points          /// </summary>          /// <param name="args">command-line args</param>          static void Main(string[] args)          {              // loop while there's more input              string input = Console.ReadLine();              while (input[0] != 'q')              {                  // extract point coordinates from string                  GetInputValuesFromString(input);                    // Add your code between this comment                  // and the comment below. You can of                  // course add more space between the                  // comments as needed                    float deltaX = point2X - point1X;                  float deltaY = point2Y - point1Y;                  Double distanceBetweenPoints = Math.Sqrt((Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));                  Double angleRadians = Math.Atan2((double)deltaX, (double)deltaY);                  Double angleDegrees = angleRadians * (180 / Math.PI);                  Console.WriteLine("{0} {1}" ,distanceBetweenPoints,angleDegrees);                    // Don't add or modify any code below                  // this comment                  input = Console.ReadLine();              }          }            /// <summary>          /// Extracts point coordinates from the given input string          /// </summary>          /// <param name="input">input string</param>          static void GetInputValuesFromString(string input)          {              // extract point 1 x              int spaceIndex = input.IndexOf(' ');              point1X = float.Parse(input.Substring(0, spaceIndex));                // move along string and extract point 1 y              input = input.Substring(spaceIndex + 1);              spaceIndex = input.IndexOf(' ');              point1Y = float.Parse(input.Substring(0, spaceIndex));                // move along string and extract point 2 x              input = input.Substring(spaceIndex + 1);              spaceIndex = input.IndexOf(' ');              point2X = float.Parse(input.Substring(0, spaceIndex));                // point 2 y is the rest of the string              input = input.Substring(spaceIndex + 1);              point2Y = float.Parse(input);                #region Unfortunately, Mono doesn't have a Split method!              //string[] values = input.Split(' ');              //point1X = float.Parse(values[0]);              //point1Y = float.Parse(values[1]);              //point2X = float.Parse(values[2]);              //point2Y = float.Parse(values[3]);              

No comments:

Post a Comment